From 5d18f6a21ff9efe59d31345da867d0428b12281d Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 4 Oct 2024 16:30:56 +0530 Subject: [PATCH] Improved: naming conventions of the state and methods and other variable related to category jobs (#299) --- .env.example | 3 ++- src/store/modules/job/JobState.ts | 2 +- src/store/modules/job/actions.ts | 10 ++++---- src/store/modules/job/getters.ts | 4 +-- src/store/modules/job/index.ts | 2 +- src/store/modules/job/mutation-types.ts | 2 +- src/store/modules/job/mutations.ts | 4 +-- src/store/modules/user/actions.ts | 2 +- src/views/catalog-product-details.vue | 34 ++++++++++++------------- src/views/job-actions-popover.vue | 6 ++--- 10 files changed, 35 insertions(+), 34 deletions(-) diff --git a/.env.example b/.env.example index c186a06a..181fa134 100644 --- a/.env.example +++ b/.env.example @@ -11,7 +11,8 @@ VUE_APP_BASE_URL= VUE_APP_ORDER_IN_BRKRNG_FILTERS=["orderTypeId: SALES_ORDER", "facilityId: _NA_", "orderStatusId: ORDER_APPROVED", "!orderItemStatusId: ITEM_CANCELLED" ] VUE_APP_PERMISSION_ID= VUE_APP_ALIAS= -VUE_APP_CTGRY_AND_BRKRNG_JOB=["JOB_REL_PREODR_CAT", "JOB_RLS_ORD_DTE"] +VUE_APP_CTGRY_JOB=["JOB_REL_PREODR_CAT", "JOB_RLS_ORD_DTE"] +VUE_APP_BROKERING_JOB="JOB_BKR_ORD" VUE_APP_DEFAULT_ALIAS= VUE_APP_DEFAULT_LOG_LEVEL="error" VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login" \ No newline at end of file diff --git a/src/store/modules/job/JobState.ts b/src/store/modules/job/JobState.ts index 3cc324c8..c75deb89 100644 --- a/src/store/modules/job/JobState.ts +++ b/src/store/modules/job/JobState.ts @@ -8,6 +8,6 @@ export default interface JobState { items: any[]; }, polling: boolean, - ctgryAndBrkrngJobs: any, + categoryJobs: any, brokeringJob: any } \ No newline at end of file diff --git a/src/store/modules/job/actions.ts b/src/store/modules/job/actions.ts index aa230e44..a5e391ae 100644 --- a/src/store/modules/job/actions.ts +++ b/src/store/modules/job/actions.ts @@ -79,10 +79,10 @@ const actions: ActionTree = { return { jobResponse, logResponse }; } }, - async fetchCtgryAndBrkrngJobs ({ commit }) { + async fetchCategoryJobs ({ commit }) { let resp, jobs = {} as any const requests = [] - const systemJobEnumIds = JSON.parse(process.env.VUE_APP_CTGRY_AND_BRKRNG_JOB) + const systemJobEnumIds = JSON.parse(process.env.VUE_APP_CTGRY_JOB) try { let params = { @@ -171,7 +171,7 @@ const actions: ActionTree = { } catch (error) { console.error(error) } finally { - commit(types.JOB_CTGRY_AND_BRKRNG_UPDATED, jobs) + commit(types.JOB_CATEGORY_JOBS_UPDATED, jobs) } return jobs; }, @@ -220,8 +220,8 @@ const actions: ActionTree = { commit(types.JOB_BROKERING_JOB_UPDATED, jobInfo) }, - clearCtgryAndBrkrngJobs({commit}) { - commit(types.JOB_CTGRY_AND_BRKRNG_UPDATED, { jobs: [] }) + clearCategoryJobs({commit}) { + commit(types.JOB_CATEGORY_JOBS_UPDATED, { jobs: [] }) } } export default actions; \ No newline at end of file diff --git a/src/store/modules/job/getters.ts b/src/store/modules/job/getters.ts index 0ff63d3d..3dc2c0ea 100644 --- a/src/store/modules/job/getters.ts +++ b/src/store/modules/job/getters.ts @@ -18,8 +18,8 @@ const getters: GetterTree = { isJobPending(state) { return (state.list.total + state.logs.total) > 0; }, - getCtgryAndBrkrngJob: (state) => (systemJobEnumId: string) => { - return state.ctgryAndBrkrngJobs[systemJobEnumId] ? state.ctgryAndBrkrngJobs[systemJobEnumId] : {}; + getCategoryJob: (state) => (systemJobEnumId: string) => { + return state.categoryJobs[systemJobEnumId] ? state.categoryJobs[systemJobEnumId] : {}; }, getBrokeringJob(state) { return state.brokeringJob; diff --git a/src/store/modules/job/index.ts b/src/store/modules/job/index.ts index 63f919fa..c8811b1b 100644 --- a/src/store/modules/job/index.ts +++ b/src/store/modules/job/index.ts @@ -17,7 +17,7 @@ const jobModule: Module = { total: 0 }, polling: false, - ctgryAndBrkrngJobs: {}, + categoryJobs: {}, brokeringJob: {} }, getters, diff --git a/src/store/modules/job/mutation-types.ts b/src/store/modules/job/mutation-types.ts index ba146cad..4a18b905 100644 --- a/src/store/modules/job/mutation-types.ts +++ b/src/store/modules/job/mutation-types.ts @@ -3,5 +3,5 @@ export const JOB_LIST_UPDATED = SN_JOB + '/LIST_UPDATED' export const JOB_LOGS_UPDATED = SN_JOB + '/LOGS_UPDATED' export const JOB_POLLING_UPDATED = SN_JOB + '/POLLING_UPDATED' export const JOB_UPDATED = SN_JOB + '/UPDATED' -export const JOB_CTGRY_AND_BRKRNG_UPDATED = SN_JOB + '/CTGRY_AND_BRKRNG_UPDATED' +export const JOB_CATEGORY_JOBS_UPDATED = SN_JOB + '/CTGRY_AND_BRKRNG_UPDATED' export const JOB_BROKERING_JOB_UPDATED = SN_JOB + '/BROKERING_JOB_UPDATED' \ No newline at end of file diff --git a/src/store/modules/job/mutations.ts b/src/store/modules/job/mutations.ts index f9058698..79349efe 100644 --- a/src/store/modules/job/mutations.ts +++ b/src/store/modules/job/mutations.ts @@ -19,8 +19,8 @@ const mutations: MutationTree = { state.list.total = payload.total state.polling = payload.polling }, - [types.JOB_CTGRY_AND_BRKRNG_UPDATED] (state, payload) { - state.ctgryAndBrkrngJobs = payload; + [types.JOB_CATEGORY_JOBS_UPDATED] (state, payload) { + state.categoryJobs = payload; }, [types.JOB_BROKERING_JOB_UPDATED] (state, payload) { state.brokeringJob = payload; diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 0029dba6..46dee871 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -127,7 +127,7 @@ const actions: ActionTree = { this.dispatch("product/resetProductList") this.dispatch("product/resetCatalogProducts") this.dispatch("order/resetOrderQuery") - this.dispatch("job/clearCtgryAndBrkrngJobs") + this.dispatch("job/clearCategoryJobs") this.dispatch("util/clearInvConfigs") dispatch("setOmsRedirectionInfo", { url: "", token: "" }) resetPermissions(); diff --git a/src/views/catalog-product-details.vue b/src/views/catalog-product-details.vue index 3216c519..4f9f322f 100644 --- a/src/views/catalog-product-details.vue +++ b/src/views/catalog-product-details.vue @@ -273,7 +273,7 @@

{{ $t('Related jobs') }}

-
+
@@ -285,13 +285,13 @@
- +

{{ $t('Pre-sell computation') }}

-

{{ getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT').lastRunTime && timeTillJob(getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT').lastRunTime) }}

+

{{ getCategoryJob('JOB_REL_PREODR_CAT').lastRunTime && timeTillJob(getCategoryJob('JOB_REL_PREODR_CAT').lastRunTime) }}

-

{{ getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT').runTime ? timeTillJob(getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT').runTime) : $t('disabled')}}

+

{{ getCategoryJob('JOB_REL_PREODR_CAT').runTime ? timeTillJob(getCategoryJob('JOB_REL_PREODR_CAT').runTime) : $t('disabled')}}

@@ -305,13 +305,13 @@
- +

{{ $t('Auto releasing') }}

-

{{ getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE').lastRunTime && timeTillJob(getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE').lastRunTime) }}

+

{{ getCategoryJob('JOB_RLS_ORD_DTE').lastRunTime && timeTillJob(getCategoryJob('JOB_RLS_ORD_DTE').lastRunTime) }}

-

{{ getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE').runTime ? timeTillJob(getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE').runTime) : $t('disabled')}}

+

{{ getCategoryJob('JOB_RLS_ORD_DTE').runTime ? timeTillJob(getCategoryJob('JOB_RLS_ORD_DTE').runTime) : $t('disabled')}}

@@ -453,14 +453,14 @@ export default defineComponent({ listingJobRunTime: 0, backorderCategoryId: '', preOrderCategoryId: '', - isCtgryAndBrkrngJobsLoaded: false + isCategoryJobsLoaded: false } }, computed: { ...mapGetters({ product: "product/getCurrentCatalogProduct", currentEComStore: 'user/getCurrentEComStore', - getCtgryAndBrkrngJob: "job/getCtgryAndBrkrngJob", + getCategoryJob: "job/getCategoryJob", getInventoryConfig: "util/getInventoryConfig", brokeringJob: "job/getBrokeringJob" }) @@ -483,7 +483,7 @@ export default defineComponent({ console.error("Failed to get pre-order/backorder categories") } await this.getShopifyConfigsByStore() - await this.getCtgryAndBrkrngJobs() + await this.getCategoryJobs() await this.getVariantDetails() }, methods: { @@ -549,11 +549,11 @@ export default defineComponent({ await this.prepareShopListings() await this.preparePoSummary() }, - async getCtgryAndBrkrngJobs() { - const systemJobEnumIds = JSON.parse(process.env.VUE_APP_CTGRY_AND_BRKRNG_JOB) + async getCategoryJobs() { + const systemJobEnumIds = JSON.parse(process.env.VUE_APP_CTGRY_JOB) this.store.dispatch('job/fetchBrokeringJob') - this.store.dispatch('job/fetchCtgryAndBrkrngJobs', { systemJobEnumIds }).then(() => { - this.isCtgryAndBrkrngJobsLoaded = true + this.store.dispatch('job/fetchCategoryJobs', { systemJobEnumIds }).then(() => { + this.isCategoryJobsLoaded = true }) }, async openJobActionsPopover(event: Event, job: any, jobTitle: string, isMaargJob = false) { @@ -878,7 +878,7 @@ export default defineComponent({ } this.poSummary.body = this.$t("When this product entered there was no sellable inventory and was available in", { categoryName, poItemATP: this.poAndAtpDetails.activePo.quantity , poId: this.poAndAtpDetails.activePo.orderExternalId ? this.poAndAtpDetails.activePo.orderExternalId : this.poAndAtpDetails.activePo.orderId }); } else if (!this.poSummary.eligible && !hasCategory) { - const presellingJob = this.getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT'); + const presellingJob = this.getCategoryJob('JOB_REL_PREODR_CAT'); if (Object.keys(presellingJob).length === 0 || !presellingJob.runTime) { this.poSummary.header = this.$t("Pre-sell processing disabled"); } else { @@ -891,7 +891,7 @@ export default defineComponent({ } } else if (this.poSummary.eligible && !hasCategory) { const categoryName = this.poAndAtpDetails.activePo?.isNewProduct === "Y" ? 'pre-order' : 'back-order'; - const presellingJob = this.getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT'); + const presellingJob = this.getCategoryJob('JOB_REL_PREODR_CAT'); if (Object.keys(presellingJob).length === 0 || !presellingJob.runTime) { this.poSummary.header = this.$t("Pre-sell processing disabled"); } else { @@ -900,7 +900,7 @@ export default defineComponent({ this.poSummary.body = this.$t("This product will begin pre-selling because it is out of stock and purchase order is available.", { poId: this.poAndAtpDetails.activePo.orderExternalId ? this.poAndAtpDetails.activePo.orderExternalId : this.poAndAtpDetails.activePo.orderId }); } else if (!this.poSummary.eligible && hasCategory) { const categoryName = hasPreOrderCategory ? 'pre-order' : 'back-order'; - const presellingJob = this.getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT'); + const presellingJob = this.getCategoryJob('JOB_REL_PREODR_CAT'); if (Object.keys(presellingJob).length === 0 || !presellingJob.runTime) { this.poSummary.header = this.$t("Pre-sell processing disabled"); } else { diff --git a/src/views/job-actions-popover.vue b/src/views/job-actions-popover.vue index 3d89da84..b7d50ff2 100644 --- a/src/views/job-actions-popover.vue +++ b/src/views/job-actions-popover.vue @@ -81,7 +81,7 @@ export default defineComponent({ if (!hasError(resp)) { showToast(translate('Service has been scheduled')) - await Promise.allSettled([this.store.dispatch('job/fetchBrokeringJob'), this.store.dispatch('job/fetchCtgryAndBrkrngJobs')]) + await Promise.allSettled([this.store.dispatch('job/fetchBrokeringJob'), this.store.dispatch('job/fetchCategoryJobs')]) } else { showToast(translate('Something went wrong')) } @@ -105,7 +105,7 @@ export default defineComponent({ if (!hasError(resp)) { showToast(translate('Job cancelled successfully')) - await Promise.allSettled([this.store.dispatch('job/fetchBrokeringJob'), this.store.dispatch('job/fetchCtgryAndBrkrngJobs')]) + await Promise.allSettled([this.store.dispatch('job/fetchBrokeringJob'), this.store.dispatch('job/fetchCategoryJobs')]) } else { showToast(translate('Something went wrong, could not cancel the job')) } @@ -139,7 +139,7 @@ export default defineComponent({ if (!hasError(resp)) { showToast(translate('Service has been scheduled')); - await Promise.allSettled([this.store.dispatch('job/fetchBrokeringJob'), this.store.dispatch('job/fetchCtgryAndBrkrngJobs')]) + await Promise.allSettled([this.store.dispatch('job/fetchBrokeringJob'), this.store.dispatch('job/fetchCategoryJobs')]) } else { showToast(translate('Something went wrong')) }