Skip to content

Commit

Permalink
Improved: naming conventions of the state and methods and other varia…
Browse files Browse the repository at this point in the history
…ble related to category jobs (hotwax#299)
  • Loading branch information
amansinghbais committed Oct 4, 2024
1 parent f1cef0a commit 5d18f6a
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/store/modules/job/JobState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export default interface JobState {
items: any[];
},
polling: boolean,
ctgryAndBrkrngJobs: any,
categoryJobs: any,
brokeringJob: any
}
10 changes: 5 additions & 5 deletions src/store/modules/job/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ const actions: ActionTree<JobState, RootState> = {
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 = {
Expand Down Expand Up @@ -171,7 +171,7 @@ const actions: ActionTree<JobState, RootState> = {
} catch (error) {
console.error(error)
} finally {
commit(types.JOB_CTGRY_AND_BRKRNG_UPDATED, jobs)
commit(types.JOB_CATEGORY_JOBS_UPDATED, jobs)
}
return jobs;
},
Expand Down Expand Up @@ -220,8 +220,8 @@ const actions: ActionTree<JobState, RootState> = {
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;
4 changes: 2 additions & 2 deletions src/store/modules/job/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const getters: GetterTree <JobState, RootState> = {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/job/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const jobModule: Module<JobState, RootState> = {
total: 0
},
polling: false,
ctgryAndBrkrngJobs: {},
categoryJobs: {},
brokeringJob: {}
},
getters,
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/job/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 2 additions & 2 deletions src/store/modules/job/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const mutations: MutationTree <JobState> = {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const actions: ActionTree<UserState, RootState> = {
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();
Expand Down
34 changes: 17 additions & 17 deletions src/views/catalog-product-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
<h3>{{ $t('Related jobs') }}</h3>
</ion-card-title>
</ion-card-header>
<div v-if="!isCtgryAndBrkrngJobsLoaded">
<div v-if="!isCategoryJobsLoaded">
<ion-item>
<ion-skeleton-text animated style="height: 30%; width: 40%;" />
</ion-item>
Expand All @@ -285,13 +285,13 @@
</ion-item>
</div>
<div v-else>
<ion-item v-if="Object.keys(getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT')).length" detail button @click.stop="openJobActionsPopover($event, getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT'), 'Pre-sell computation')">
<ion-item v-if="Object.keys(getCategoryJob('JOB_REL_PREODR_CAT')).length" detail button @click.stop="openJobActionsPopover($event, getCategoryJob('JOB_REL_PREODR_CAT'), 'Pre-sell computation')">
<ion-label class="ion-text-wrap">
<h3>{{ $t('Pre-sell computation') }}</h3>
<p>{{ getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT').lastRunTime && timeTillJob(getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT').lastRunTime) }}</p>
<p>{{ getCategoryJob('JOB_REL_PREODR_CAT').lastRunTime && timeTillJob(getCategoryJob('JOB_REL_PREODR_CAT').lastRunTime) }}</p>
</ion-label>
<ion-label slot="end">
<p>{{ getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT').runTime ? timeTillJob(getCtgryAndBrkrngJob('JOB_REL_PREODR_CAT').runTime) : $t('disabled')}}</p>
<p>{{ getCategoryJob('JOB_REL_PREODR_CAT').runTime ? timeTillJob(getCategoryJob('JOB_REL_PREODR_CAT').runTime) : $t('disabled')}}</p>
</ion-label>
</ion-item>

Expand All @@ -305,13 +305,13 @@
</ion-label>
</ion-item>

<ion-item v-if="Object.keys(getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE')).length" detail button @click="openJobActionsPopover($event, getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE'), 'Auto releasing')">
<ion-item v-if="Object.keys(getCategoryJob('JOB_RLS_ORD_DTE')).length" detail button @click="openJobActionsPopover($event, getCategoryJob('JOB_RLS_ORD_DTE'), 'Auto releasing')">
<ion-label class="ion-text-wrap">
<h3>{{ $t('Auto releasing') }}</h3>
<p>{{ getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE').lastRunTime && timeTillJob(getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE').lastRunTime) }}</p>
<p>{{ getCategoryJob('JOB_RLS_ORD_DTE').lastRunTime && timeTillJob(getCategoryJob('JOB_RLS_ORD_DTE').lastRunTime) }}</p>
</ion-label>
<ion-label slot="end">
<p>{{ getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE').runTime ? timeTillJob(getCtgryAndBrkrngJob('JOB_RLS_ORD_DTE').runTime) : $t('disabled')}}</p>
<p>{{ getCategoryJob('JOB_RLS_ORD_DTE').runTime ? timeTillJob(getCategoryJob('JOB_RLS_ORD_DTE').runTime) : $t('disabled')}}</p>
</ion-label>
</ion-item>
</div>
Expand Down Expand Up @@ -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"
})
Expand All @@ -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: {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/views/job-actions-popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
}
Expand All @@ -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'))
}
Expand Down Expand Up @@ -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'))
}
Expand Down

0 comments on commit 5d18f6a

Please sign in to comment.