Skip to content

Commit

Permalink
Merge pull request #1 from ymaheshwari1/#ew3j63
Browse files Browse the repository at this point in the history
Improved: code for the count page to redirect the user to search and also   updated the showToast function to add custom buttons(#ew3j63)
  • Loading branch information
adityasharma7 authored Oct 19, 2021
2 parents 49dd2bf + f640bb3 commit 4ac08cd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
7 changes: 7 additions & 0 deletions changelogs/unreleased/-ew3j63.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: 'Improved: code for the count page to redirect the user to search and also
updated the showToast function to add custom buttons'
ticket_id: "#ew3j63"
merge_request: 1
author: Yash Maheshwari
type: changed
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"The products in the upload list will be removed.": "The products in the upload list will be removed.",
"Ok": "Ok",
"Cancel": "Cancel",
"Loading": "Loading"
"Loading": "Loading",
"Item added to upload list": "Item added to upload list"
}
26 changes: 17 additions & 9 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ import { toastController } from '@ionic/vue';

// TODO Remove it when HC APIs are fully REST compliant
const hasError = (response: any) => {
return !!response.data._ERROR_MESSAGE_ || !!response.data._ERROR_MESSAGE_LIST_;
return !!response.data._ERROR_MESSAGE_ || !!response.data._ERROR_MESSAGE_LIST_;
}

const showToast = async (message: string) => {
const toast = await toastController
.create({
message,
duration: 3000,
position: 'top',
})
return toast.present();
const showToast = async (message: string, configButtons?: any) => {
const defaultButtons = [{
text: 'Dismiss',
role: 'cancel'
}]

if (configButtons) defaultButtons.push(...configButtons);

const toast = await toastController
.create({
message: message,
duration: 3000,
position: 'top',
buttons: defaultButtons
})
return toast.present();
}

export { showToast, hasError }
11 changes: 11 additions & 0 deletions src/views/count.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import { colorPaletteOutline, resize, saveOutline } from "ionicons/icons";
import { mapGetters, useStore } from "vuex";
import { showToast } from "@/utils";
import { translate } from "@/i18n";
import { useRouter } from "vue-router";
export default defineComponent({
name: "Count",
Expand Down Expand Up @@ -101,16 +102,26 @@ export default defineComponent({
updateProductInventoryCount() {
if (this.product.quantity) {
this.store.dispatch('product/updateInventoryCount', this.product);
showToast(translate("Item added to upload list"), [{
text: translate('View'),
role: 'view',
handler: () => {
this.router.push('/upload')
}
}])
this.router.push('/search')
} else {
showToast(translate("Enter the stock count for the product"))
}
}
},
setup() {
const store = useStore();
const router = useRouter();
return {
store,
router,
colorPaletteOutline,
resize,
saveOutline,
Expand Down

0 comments on commit 4ac08cd

Please sign in to comment.