diff --git a/src/locales/en.json b/src/locales/en.json index c72b51ea..4b6fd306 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -7,6 +7,7 @@ "Allocation": "Allocation", "Are you sure you want to save these changes?": "Are you sure you want to save these changes?", "Auto cancelations": "Auto cancelations", + "Auto cancel days updated": "Auto cancel days updated", "Import all products from Shopify. Make sure you run this before importing orders in bulk during intial setup.": "Import all products from Shopify. Make sure you run this before importing orders in bulk during intial setup.", "All unsaved changes will be lost. Are you sure you want to leave this page.": "All unsaved changes will be lost. Are you sure you want to leave this page.", "Archived": "Archived", @@ -183,6 +184,7 @@ "Unfillable orders": "Unfillable orders", "Unfulfilled orders that pass their auto cancelation date will be canceled automatically in HotWax Commerce. They will also be canceled in Shopify if upload for canceled orders is enabled.": "Unfulfilled orders that pass their auto cancelation date will be canceled automatically in HotWax Commerce. They will also be canceled in Shopify if upload for canceled orders is enabled.", "Webhooks": "Webhooks", + "Unable to edit auto cancel days": "Unable to edit auto cancel days", "Upload Pending Process": "Upload Pending Process", "Update shipping dates in Shopify": "Update shipping dates in Shopify", "When importing historical completed orders, this should be turned off.": "When importing historical completed orders, this should be turned off.", diff --git a/src/services/JobService.ts b/src/services/JobService.ts index 47485091..a35b1f15 100644 --- a/src/services/JobService.ts +++ b/src/services/JobService.ts @@ -39,11 +39,27 @@ const fetchTemporalExpression = async (payload: any): Promise => { }); } +const updateAutoCancelDays = async (payload: any): Promise => { + return api({ + url: "service/updateProductStore", + method: "post", + data: payload + }); +} +const getAutoCancelDays = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }); +} export const JobService = { fetchJobDescription, fetchJobInformation, fetchTemporalExpression, updateJob, - scheduleJob + scheduleJob, + updateAutoCancelDays, + getAutoCancelDays } \ No newline at end of file diff --git a/src/views/Orders.vue b/src/views/Orders.vue index ff9ea06a..5bb297c5 100644 --- a/src/views/Orders.vue +++ b/src/views/Orders.vue @@ -82,7 +82,10 @@ {{ $t("Days") }} - + + + {{ $t("Save") }} + {{ $t("Check daily") }} @@ -183,6 +186,7 @@ import JobConfiguration from '@/components/JobConfiguration.vue'; import { DateTime } from 'luxon'; import { hasError, isFutureDate, showToast } from '@/utils'; import emitter from '@/event-bus'; +import { JobService } from '@/services/JobService' export default defineComponent({ name: 'Orders', @@ -220,7 +224,8 @@ export default defineComponent({ currentJobStatus: '', freqType: '', isJobDetailAnimationCompleted: false, - isDesktop: isPlatform('desktop') + isDesktop: isPlatform('desktop'), + autoCancelDays: '' } }, computed: { @@ -274,6 +279,23 @@ export default defineComponent({ await this.store.dispatch('webhook/unsubscribeWebhook', { webhookId: webhook?.id, shopifyConfigId: this.shopifyConfigId }) } }, + async updateAutoCancelDays(autoCancelDays: number){ + const payload = { + 'productStoreId': this.currentEComStore.productStoreId, + 'daysToCancelNonPay': autoCancelDays + } + try { + const resp = await JobService.updateAutoCancelDays(payload); + if (resp.status === 200 && !hasError(resp)) { + showToast(translate("Auto cancel days updated")); + } else { + showToast(translate("Unable to edit auto cancel days")); + } + } catch (err) { + showToast(translate('Something went wrong')) + console.error(err) + } + }, async addBatch() { const batchmodal = await modalController.create({ component: BatchModal @@ -410,7 +432,7 @@ export default defineComponent({ return jobAlert.present(); } }, - mounted () { + async mounted () { this.store.dispatch("job/fetchJobs", { "inputFields":{ "systemJobEnumId": Object.values(this.jobEnums), @@ -424,6 +446,25 @@ export default defineComponent({ } }); this.store.dispatch('webhook/fetchWebhooks') + + const payload = { + "inputFields": { + 'productStoreId': this.currentEComStore.productStoreId, + }, + "fieldList": [ 'daysToCancelNonPay' ], + "entityName": "ProductStore", + "noConditionFind": "Y" + } + try { + const resp = await JobService.getAutoCancelDays(payload); + if (resp.status === 200 && !hasError(resp) && resp.data.docs?.length > 0 ) { + this.autoCancelDays = resp.data.docs[0].daysToCancelNonPay; + } else { + console.error(resp) + } + } catch (err) { + console.error(err) + } }, setup() { const store = useStore();