Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/hotwax/job-manager into #2f…
Browse files Browse the repository at this point in the history
…2h8hu
  • Loading branch information
rathoreprashant committed Jul 19, 2022
2 parents 311758d + d8e9637 commit 2b78a7f
Show file tree
Hide file tree
Showing 24 changed files with 486 additions and 30 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ VUE_APP_CACHE_MAX_AGE=3600
VUE_APP_VIEW_SIZE=10
VUE_APP_JOB_FREQUENCY_TYPE={"BOPIS_CORRECTION":"default","PRE_ORDER_CTLG":"default","ADD_PRODR_TG_SHPFY":"default","REMV_PRODR_TG_SHPFY":"default","ADD_PRODR_SHPG_DTE_SHPFY":"default","REMV_PRODR_SHPG_DTE_SHPFY":"default","BACK_ORDER_CTLG":"default","ADD_BACKODR_TG_SHPFY":"default","IMP_NEW_ORDERS":"default","IMP_CANCELLED_ORDERS":"default","REMV_BACKODR_TG_SHPFY":"default","ADD_BACKODR_SHPG_DTE_SHPFY":"default","IMP_CANCELLED_ITEMS":"default","REMV_BACKODR_SHPG_DTE_SHPFY":"default","REALLOC_PRODR":"default","AUTO_RELSE_DAILY":"default","IMP_PAYMENT_STATUS":"default","IMP_RETURNS":"default","UPLD_CMPLT_ORDRS":"default","UPLD_CNCLD_ORDRS":"default","UPLD_REFUNDS":"default","NTS_PRMS_DT_CHNG":"default","REJ_ORDR":"default","UNFIL_ORDERS":"default","AUTO_CNCL_DAL":"default","BTCH_BRKR_ORD":"default","LIST_PRE_ORDER":"slow","LIST_BACK_ORDER":"slow","IMP_PRDTS":"default","SYNC_PRDTS":"slow","HARD_SYNC":"slow","IMP_PRDTS_BLK":"default","IMP_ORDERS_BLK":"default"}
VUE_APP_ODR_JOB_ENUMS={"IMP_NEW_ORDERS":"JOB_IMP_ORD","IMP_CANCELLED_ORDERS":"JOB_IMP_ORD_CNCL","IMP_CANCELLED_ITEMS":"JOB_IMP_ITM_CNCL","IMP_PAYMENT_STATUS":"JOB_IMP_PYMNT_STTS","IMP_RETURNS":"JOB_IMP_RTN","UPLD_CMPLT_ORDRS":"JOB_UL_CMPLT_ORD","UPLD_CNCLD_ORDRS":"JOB_UL_CNCLD_ORD","UPLD_REFUNDS":"JOB_UL_REFUNDS","NTS_PRMS_DT_CHNG":"JOB_UL_PRMS_DTE_ORD","REJ_ORDR":"JOB_BKR_REJ_ORD","UNFIL_ORDERS":"JOB_BKR_ORD_UNF","AUTO_CNCL_DAL":"JOB_CNCL_ORD_DTE","BTCH_BRKR_ORD":"JOB_BKR_ORD"}
VUE_APP_PRODR_JOB_ENUMS={"PRE_ORDER_CTLG":"JOB_CAT_REL_PREODR","ADD_PRODR_TG_SHPFY":"JOB_ADD_PREORD_VRT","REMV_PRODR_TG_SHPFY":"JOB_RMV_PREORD_VRT","ADD_PRODR_SHPG_DTE_SHPFY":"JOB_ADD_PREORD_SKU","REMV_PRODR_SHPG_DTE_SHPFY":"JOB_RMV_PREORD_SKU","BACK_ORDER_CTLG":"JOB_CAT_REL_BACKORD","ADD_BACKODR_TG_SHPFY":"JOB_ADD_BACKORD_VRT","REMV_BACKODR_TG_SHPFY":"JOB_RMV_BACKORD_VRT","ADD_BACKODR_SHPG_DTE_SHPFY":"JOB_ADD_BACKORD_SKU","REMV_BACKODR_SHPG_DTE_SHPFY":"JOB_RMV_BACKORD_SKU","REALLOC_PRODR":"JOB_REALOC_PO","AUTO_RELSE_DAILY":"JOB_RLS_ORD_DTE"}
VUE_APP_PRODR_JOB_ENUMS={"PRE_ORDER_CTLG":"JOB_CAT_REL_PREODR","ADD_PRODR_TG_SHPFY":"JOB_ADD_PREORD_VRT","REMV_PRODR_TG_SHPFY":"JOB_RMV_PREORD_VRT","ADD_PRODR_SHPG_DTE_SHPFY":"JOB_ADD_PREORD_SKU","JOB_UPD_PREORD_SKU":"JOB_UPD_PREORD_SKU","REMV_PRODR_SHPG_DTE_SHPFY":"JOB_RMV_PREORD_SKU","BACK_ORDER_CTLG":"JOB_CAT_REL_BACKORD","ADD_BACKODR_TG_SHPFY":"JOB_ADD_BACKORD_VRT","REMV_BACKODR_TG_SHPFY":"JOB_RMV_BACKORD_VRT","ADD_BACKODR_SHPG_DTE_SHPFY":"JOB_ADD_BACKORD_SKU","JOB_UPD_BACKORD_SKU":"JOB_UPD_BACKORD_SKU","REMV_BACKODR_SHPG_DTE_SHPFY":"JOB_RMV_BACKORD_SKU","REALLOC_PRODR":"JOB_REALOC_PO","AUTO_RELSE_DAILY":"JOB_RLS_ORD_DTE"}
VUE_APP_PRD_JOB_ENUMS={"IMP_PRDTS":"JOB_IMP_PROD_NEW","SYNC_PRDTS":"JOB_IMP_PROD_UPD"}
VUE_APP_INV_JOB_ENUMS={"HARD_SYNC":"JOB_UL_INV","BOPIS_CORRECTION":"JOB_BOPIS_RALC"}
VUE_APP_INITIAL_JOB_ENUMS={"IMP_PRDTS_BLK":"JOB_IMP_PROD_NEW_BLK","IMP_ORDERS_BLK":"JOB_IMP_ORD_BLK"}
VUE_APP_INITIAL_JOB_ENUMS={"IMP_PRDTS_BLK":"JOB_IMP_PROD_NEW_BLK","IMP_ORDERS_BLK":"JOB_IMP_ORD_BLK","UL_PRCS":"JOB_UL_PRCS"}
VUE_APP_JOB_TITLES={"JOB_IMP_PROD_NEW":"Import products","JOB_IMP_PROD_UPD":"Sync products","JOB_IMP_ORD_CNCL":"Cancelled orders","JOB_IMP_ORD":"New orders","JOB_IMP_ITM_CNCL":"Cancelled items","JOB_UL_CNCLD_ORD":"Cancelled orders","JOB_UL_CMPLT_ORD":"Completed orders","JOB_IMP_PYMNT_STTS":"Payment status","JOB_IMP_RTN":"Returns","JOB_UL_REFUNDS":"Refunds","JOB_BKR_REJ_ORD":"Rejected orders","JOB_BKR_ORD_UNF":"Unfillable orders","JOB_UL_INV":"Hard sync"}
VUE_APP_INITIAL_JOB_TYPES={"JOB_IMP_PROD_NEW_BLK":"products","JOB_IMP_ORD_BLK":"orders"}
VUE_APP_BASE_URL=
VUE_APP_BATCH_JOB_ENUMS={"JOB_BKR_ORD_UNF":{"id":"JOB_BKR_ORD_UNF","facilityId":"_NA_","unfillable": true},"JOB_BKR_ORD":{"id": "JOB_BKR_ORD","facilityId":"_NA_","unfillable": false},"JOB_BKR_PREORD_UNF":{"id":"JOB_BKR_PREORD_UNF","facilityId":"PRE_ORDER_PARKING","unfillable":true},"JOB_BKR_PREORD":{"id":"JOB_BKR_PREORD","facilityId":"PRE_ORDER_PARKING","unfillable":false},"JOB_BKR_BACKORD_UNF":{"id":"JOB_BKR_BACKORD_UNF","facilityId":"BACKORDER_PARKING","unfillable":true},"JOB_BKR_BACKORD":{"id":"JOB_BKR_BACKORD","facilityId":"BACKORDER_PARKING","unfillable":false}}
VUE_APP_WEBHOOK_ENUMS={"NEW_PRODUCTS":"products/create","DELETE_PRODUCTS":"products/update","NEW_ORDERS":"orders/create","CANCELLED_ORDERS":"orders/cancelled","PAYMENT_STATUS":"orders/paid","RETURNS":"","BULK_OPERATIONS_FINISH":"bulk_operations/finish"}
2 changes: 1 addition & 1 deletion src/components/InitialJobConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</ion-item>
</ion-list>

<ion-button size="small" fill="outline" expand="block" @click="runJob('Orders')">{{ $t("Run import") }}</ion-button>
<ion-button size="small" fill="outline" expand="block" :disabled="!lastShopifyOrderId" @click="runJob('Orders')">{{ $t("Run import") }}</ion-button>
</section>
</template>

Expand Down
10 changes: 10 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"Canceling this job will cancel this occurrence and all following occurrences. This job will have to be re-enabled manually to run it again.": "Canceling this job will cancel this occurrence and all following occurrences. This job will have to be re-enabled manually to run it again.",
"Change": "Change",
"Change time zone": "Change time zone",
"Configuration missing": "Configuration missing",
"Confirm": "Confirm",
"Click the backdrop to dismiss.": "Click the backdrop to dismiss.",
"Cancelled orders": "Cancelled orders",
Expand All @@ -41,6 +42,7 @@
"Daily": "Daily",
"Dashoard": "Dashoard",
"Days": "Days",
"Delete products": "Delete products",
"Disable": "Disable",
"Dismiss": "Dismiss",
"Disabled": "Disabled",
Expand All @@ -52,6 +54,7 @@
"Every 5 minutes": "Every 5 minutes",
"Every 15 minutes": "Every 15 minutes",
"Every 30 minutes": "Every 30 minutes",
"File upload status": "File upload status",
"Fulfilled": "Fulfilled",
"Fulfillment status": "Fulfillment status",
"Hard sync": "Hard sync",
Expand All @@ -77,6 +80,7 @@
"More options": "More options",
"New broker run": "New broker run",
"New orders": "New orders",
"New products": "New products",
"No jobs have run yet": "No jobs have run yet",
"No previous occurrence": "No previous occurrence",
"Notes": "Notes",
Expand All @@ -99,6 +103,7 @@
"Pin job": "Pin job",
"Pinned jobs": "Pinned jobs",
"Pipeline": "Pipeline",
"Process Uploads": "Process Uploads",
"Product": "Product",
"Products": "Products",
"Promise date changes": "Promise date changes",
Expand Down Expand Up @@ -171,10 +176,15 @@
"Update time zone": "Update time zone",
"Use POs to manage catalog": "Use POs to manage catalog",
"Username": "Username",
"Webhook subscribed successfully": "Webhook subscribed successfully",
"Webhook unsubscribed successfully": "Webhook unsubscribed successfully",
"Would you like to update your time zone to . Your profile is currently set to . This setting can always be changed from the settings menu.": "Would you like to update your time zone to {localTimeZone}. Your profile is currently set to {profileTimeZone}. This setting can always be changed from the settings menu.",
"Unfillable": "Unfillable",
"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",
"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.",
"When using HotWax BOPIS, Shopify isn't aware of the actual inventory consumed. HotWax will automatically restore inventory automatically reduced by Shopify and deduct inventory from the correct store to maintain inventory accuracy.": "When using HotWax BOPIS, Shopify isn't aware of the actual inventory consumed. HotWax will automatically restore inventory automatically reduced by Shopify and deduct inventory from the correct store to maintain inventory accuracy."
}
90 changes: 90 additions & 0 deletions src/services/WebhookService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import api from '@/api'

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

// TODO: add the service endpoint for the new order webhook
const subscribeNewOrderWebhook = async (payload?: any): Promise <any> => {
return api ({
url: '',
method: 'post',
data: payload
})
}

// TODO: add the service endpoint for the cancelled order webhook
const subscribeCancelledOrderWebhook = async (payload?: any): Promise <any> => {
return api ({
url: '',
method: 'post',
data: payload
})
}

// TODO: add the service endpoint for the payment status webhook
const subscribePaymentStatusWebhook = async (payload?: any): Promise <any> => {
return api ({
url: '',
method: 'post',
data: payload
})
}

// TODO: add the service endpoint for the order return webhook
const subscribeReturnWebhook = async (payload?: any): Promise <any> => {
return api ({
url: '',
method: 'post',
data: payload
})
}

// TODO: add the service endpoint for the new product webhook
const subscribeNewProductsWebhook = async (payload?: any): Promise <any> => {
return api ({
url: '',
method: 'post',
data: payload
})
}

const subscribeDeleteProductsWebhook = async (payload?: any): Promise <any> => {
return api ({
url: 'service/subscribeProductDeleteWebhook',
method: 'post',
data: payload
})
}

const subscribeFileStatusUpdateWebhook = async (payload?: any): Promise <any> => {
return api ({
url: 'service/subscribeFileStatusUpdateWebhook',
method: 'post',
data: payload
})
}

const unsubscribeWebhook = async (payload?: any): Promise <any> => {
return api ({
url: 'service/removeShopifyWebhook',
method: 'post',
data: payload
})
}

export const WebhookService = {
fetchShopifyWebhooks,
subscribeNewOrderWebhook,
subscribeCancelledOrderWebhook,
subscribeFileStatusUpdateWebhook,
subscribePaymentStatusWebhook,
subscribeReturnWebhook,
subscribeNewProductsWebhook,
subscribeDeleteProductsWebhook,
unsubscribeWebhook
}
4 changes: 3 additions & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import userModule from './modules/user';
import productModule from "./modules/product"
import jobModule from "./modules/job"
import utilModule from "./modules/util"
import webhookModule from "./modules/webhook"


// TODO check how to register it from the components only
Expand Down Expand Up @@ -35,7 +36,8 @@ const store = createStore<RootState>({
'user': userModule,
'product': productModule,
'job': jobModule,
'util': utilModule
'util': utilModule,
'webhook': webhookModule
},
})

Expand Down
10 changes: 10 additions & 0 deletions src/store/modules/job/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ const actions: ActionTree<JobState, RootState> = {
job?.priority && (payload['SERVICE_PRIORITY'] = job.priority.toString())
job?.runTime && (payload['SERVICE_TIME'] = job.runTime.toString())

// assigning '' (empty string) to all the runtimeData properties whose value is "null"
job.runtimeData && Object.keys(job.runtimeData).map((key: any) => {
if (job.runtimeData[key] === 'null' ) job.runtimeData[key] = ''
})

try {
resp = await JobService.scheduleJob({ ...job.runtimeData, ...payload });
if (resp.status == 200 && !hasError(resp)) {
Expand Down Expand Up @@ -541,6 +546,11 @@ const actions: ActionTree<JobState, RootState> = {
job?.sinceId && (payload['sinceId'] = job.sinceId)
job?.runTime && (payload['SERVICE_TIME'] = job.runTime.toString())

// assigning '' (empty string) to all the runtimeData properties whose value is "null"
job.runtimeData && Object.keys(job.runtimeData).map((key: any) => {
if (job.runtimeData[key] === 'null' ) job.runtimeData[key] = ''
})

try {
resp = await JobService.scheduleJob({ ...job.runtimeData, ...payload });
if (resp.status == 200 && !hasError(resp)) {
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default interface UserState {
current: object | null;
currentEComStore: object;
instanceUrl: string;
shopifyConfig: object;
shopifyConfigId: string;
}
39 changes: 30 additions & 9 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const actions: ActionTree<UserState, RootState> = {
if (resp.data.token) {
commit(types.USER_TOKEN_CHANGED, { newToken: resp.data.token })
await dispatch('getProfile')
dispatch('getShopifyConfig')
return resp.data;
} else if (hasError(resp)) {
showToast(translate('Sorry, your username or password is incorrect. Please try again.'));
Expand Down Expand Up @@ -73,6 +72,10 @@ const actions: ActionTree<UserState, RootState> = {
}
]
})
const currentProductStoreId = resp.data?.stores[0].productStoreId;
if (currentProductStoreId) {
dispatch('getShopifyConfig', currentProductStoreId);
}

this.dispatch('util/getServiceStatusDesc')
if (resp.data.userTimeZone) {
Expand All @@ -94,6 +97,7 @@ const actions: ActionTree<UserState, RootState> = {
async setEcomStore({ commit, dispatch }, payload) {
dispatch('job/clearJobState', null, { root: true });
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, payload.eComStore);
dispatch('getShopifyConfig', payload.eComStore.productStoreId);
await UserService.setUserPreference({
'userPrefTypeId': 'SELECTED_BRAND',
'userPrefValue': payload.eComStore.productStoreId
Expand All @@ -120,14 +124,31 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_INSTANCE_URL_UPDATED, payload)
},

async getShopifyConfig({ commit }) {
const resp = await UserService.getShopifyConfig({
"entityName": "ShopifyConfig",
"noConditionFind": "Y"
})

if (resp.status === 200 && !hasError(resp)) {
commit(types.USER_SHOPIFY_CONFIG_UPDATED, resp.data.docs?.length > 0 ? resp.data.docs[0].shopifyConfigId : {});
async getShopifyConfig({ commit }, productStoreId) {
if (productStoreId) {
let resp;
const payload = {
"inputFields": {
"productStoreId": productStoreId,
},
"entityName": "ShopifyConfig",
"noConditionFind": "Y",
"fieldList": ["shopifyConfigId"]
}
try {
resp = await UserService.getShopifyConfig(payload);
if (resp.status === 200 && !hasError(resp) && resp.data?.docs) {
commit(types.USER_SHOPIFY_CONFIG_UPDATED, resp.data.docs?.length > 0 ? resp.data.docs[0].shopifyConfigId : "");
} else {
console.error(resp);
commit(types.USER_SHOPIFY_CONFIG_UPDATED, "");
}
} catch (err) {
console.error(err);
commit(types.USER_SHOPIFY_CONFIG_UPDATED, "");
}
} else {
commit(types.USER_SHOPIFY_CONFIG_UPDATED, "");
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const getters: GetterTree <UserState, RootState> = {
return state.instanceUrl;
},
getShopifyConfigId (state) {
return state.shopifyConfig;
return state.shopifyConfigId;
},
getCurrentEComStore(state) {
return state.currentEComStore
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const userModule: Module<UserState, RootState> = {
token: '',
current: null,
instanceUrl: '',
shopifyConfig: {},
shopifyConfigId: "",
currentEComStore: {
productStoreId: "",
storeName: "None"
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const mutations: MutationTree <UserState> = {
[types.USER_END_SESSION] (state) {
state.token = ''
state.current = null
state.shopifyConfig = {}
state.shopifyConfigId = ""
state.currentEComStore = {
productStoreId: "",
storeName: "None"
Expand All @@ -22,7 +22,7 @@ const mutations: MutationTree <UserState> = {
state.instanceUrl = payload;
},
[types.USER_SHOPIFY_CONFIG_UPDATED] (state, payload) {
state.shopifyConfig = payload;
state.shopifyConfigId = payload;
},
[types.USER_CURRENT_ECOM_STORE_UPDATED] (state, payload) {
state.currentEComStore = payload;
Expand Down
3 changes: 3 additions & 0 deletions src/store/modules/webhook/WebhookState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default interface WebhookState {
cached: any
}
Loading

0 comments on commit 2b78a7f

Please sign in to comment.