Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: code for the count page to redirect the user to search and also updated the showToast function to add custom buttons(#ew3j63) #1

Merged
merged 6 commits into from
Oct 19, 2021
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')
adityasharma7 marked this conversation as resolved.
Show resolved Hide resolved
} 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