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) #218

Merged
merged 13 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
}
54 changes: 51 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="updatedAutoCancelDays" type="number" />
<ion-button fill="clear" @click="updateAutoCancelDays()" 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,9 @@ export default defineComponent({
currentJobStatus: '',
freqType: '',
isJobDetailAnimationCompleted: false,
isDesktop: isPlatform('desktop')
isDesktop: isPlatform('desktop'),
autoCancelDays: '',
updatedAutoCancelDays: ''
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 could have variable names as autoCancelDays and currentAutoCancelDays. Also, instead of checking in update method we should either disable the save button if both the values are same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the requested change.

}
},
computed: {
Expand Down Expand Up @@ -274,6 +280,26 @@ export default defineComponent({
await this.store.dispatch('webhook/unsubscribeWebhook', { webhookId: webhook?.id, shopifyConfigId: this.shopifyConfigId })
}
},
async updateAutoCancelDays(){
if(this.autoCancelDays != this.updatedAutoCancelDays){
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 check if selected product store is not the None while setting and getting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the requested change.

const payload = {
'productStoreId': this.currentEComStore.productStoreId,
'daysToCancelNonPay': this.updatedAutoCancelDays
}
try {
const resp = await JobService.updateAutoCancelDays(payload);
if (resp.status === 200 && !hasError(resp)) {
showToast(translate("Auto cancel days updated"));
this.autoCancelDays = this.updatedAutoCancelDays;
} 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 @@ -408,9 +434,30 @@ export default defineComponent({
]
});
return jobAlert.present();
},
async getAutoCancelDays(){
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;
this.updatedAutoCancelDays = resp.data.docs[0].daysToCancelNonPay;
} else {
console.error(resp)
}
} catch (err) {
console.error(err)
}
}
},
mounted () {
async mounted () {
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
this.store.dispatch("job/fetchJobs", {
"inputFields":{
"systemJobEnumId": Object.values(this.jobEnums),
Expand All @@ -424,6 +471,7 @@ export default defineComponent({
}
});
this.store.dispatch('webhook/fetchWebhooks')
this.getAutoCancelDays();
},
setup() {
const store = useStore();
Expand Down