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

Implemented: functionality to save 'auto cancel days' (#2cxr1cx) #213

Merged
merged 4 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down
18 changes: 17 additions & 1 deletion src/services/JobService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,27 @@ const fetchTemporalExpression = async (payload: any): Promise <any> => {
});
}

const updateAutoCancelDays = async (payload: any): Promise <any> => {
return api({
url: "service/updateProductStore",
method: "post",
data: payload
});
}

const getAutoCancelDays = async (payload: any): Promise <any> => {
return api({
url: "performFind",
method: "post",
data: payload
});
}
export const JobService = {
fetchJobDescription,
fetchJobInformation,
fetchTemporalExpression,
updateJob,
scheduleJob
scheduleJob,
updateAutoCancelDays,
getAutoCancelDays
}
47 changes: 44 additions & 3 deletions src/views/Orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@
</ion-card-header>
<ion-item>
<ion-label class="ion-text-wrap">{{ $t("Days") }}</ion-label>
<ion-input :placeholder="$t('before auto cancelation')" />
<ion-input :placeholder="$t('before auto cancelation')" v-model.number="autoCancelDays" type="number" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also repopulate the already set value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated sir

<ion-button fill="clear" @click="updateAutoCancelDays(this.autoCancelDays)" slot="end">
{{ $t("Save") }}
</ion-button>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">{{ $t("Check daily") }}</ion-label>
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -220,7 +224,8 @@ export default defineComponent({
currentJobStatus: '',
freqType: '',
isJobDetailAnimationCompleted: false,
isDesktop: isPlatform('desktop')
isDesktop: isPlatform('desktop'),
autoCancelDays: ''
}
},
computed: {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -410,7 +432,7 @@ export default defineComponent({
return jobAlert.present();
}
},
mounted () {
async mounted () {
this.store.dispatch("job/fetchJobs", {
"inputFields":{
"systemJobEnumId": Object.values(this.jobEnums),
Expand All @@ -424,6 +446,25 @@ export default defineComponent({
}
});
this.store.dispatch('webhook/fetchWebhooks')

const payload = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement a separate method to perform this

"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();
Expand Down