Skip to content

Commit

Permalink
Implemented: Scheduled restock upload to support product identifiers …
Browse files Browse the repository at this point in the history
…& add support to only add selected items from review page(hotwax#285)
  • Loading branch information
R-Sourabh committed May 30, 2024
1 parent 884e3d6 commit ef70d89
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ VUE_APP_ALIAS={}
VUE_APP_MAPPING_TYPES={"PO": "PO_MAPPING_PREF","RSTINV": "INV_MAPPING_PREF","RSTSTK": "STK_MAPPING_PREF"}
VUE_APP_MAPPING_PO={"orderId": { "label": "Order ID", "required": true }, "productSku": { "label": "Shopify product SKU", "required": true },"orderDate": { "label": "Arrival date", "required": true }, "quantity": { "label": "Ordered quantity", "required": true }, "facility": { "label": "Facility ID", "required": true }}
VUE_APP_MAPPING_RSTINV={"productIdentification": { "label": "Product Identification", "required": true }, "quantity": { "label": "Quantity", "required": true }, "facility": { "label": "Facility ID", "required": true }}
VUE_APP_MAPPING_RSTSTK={"product": { "label": "Product", "required": true }, "facility": { "label": "Facility", "required": true }, "restockQuantity": { "label": "Restock quantity", "required": true }}
VUE_APP_MAPPING_RSTSTK={"productIdentification": { "label": "Product Identification", "required": true }, "facility": { "label": "Facility", "required": true }, "restockQuantity": { "label": "Restock quantity", "required": true }}
VUE_APP_DEFAULT_LOG_LEVEL="error"
VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login"
7 changes: 2 additions & 5 deletions src/store/modules/stock/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const actions: ActionTree<StockState, RootState> = {
},
async processUpdateRestockItems({ commit }, items) {

const productIds = items.filter((item: any) => item.product).map((item: any) => item.product);
const productIds = items.map((item: any) => item.identification);

const payload = {
productIds,
Expand All @@ -87,7 +87,7 @@ const actions: ActionTree<StockState, RootState> = {
const cachedProducts = await store.dispatch("product/fetchProducts", payload);

const initial = items.map((item: any) => {
const product = cachedProducts[item.product];
const product = cachedProducts[item.identification];

if (product) {
item.parentProductId = product?.parent?.id;
Expand All @@ -103,9 +103,6 @@ const actions: ActionTree<StockState, RootState> = {

commit(types.STOCK_SCHEDULE_ITEMS_UPDATED, initial );
},
clearRetockItems({ commit }) {
commit(types.STOCK_SCHEDULE_ITEMS_UPDATED, []);
},
async scheduledStock({ commit }, payload) {
commit(types.STOCK_SCHEDULED_INFORMATION, payload)
},
Expand Down
30 changes: 20 additions & 10 deletions src/views/ScheduledRestock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@
<ion-item-divider>
<ion-label> Required </ion-label>
</ion-item-divider>
<template :key="field" v-for="(fieldValues, field) in fields">

<ion-item v-if="fieldValues.required">
<ion-select :label="fieldValues.label" interface="popover" :placeholder = "translate('Select')" v-model="fieldMapping[field]">
<ion-item :key="field" v-for="(fieldValues, field) in fields">
<template v-if="field === 'productIdentification'">
<ion-select aria-label="identification-type-id" interface="popover" :placeholder = "translate('Select')" v-model="identificationTypeId">
<ion-select-option :key="goodIdentificationType.goodIdentificationTypeId" :value="goodIdentificationType.goodIdentificationTypeId" v-for="goodIdentificationType in goodIdentificationTypes">{{ goodIdentificationType.description }}</ion-select-option>
</ion-select>
<ion-select aria-label="identification-type-value" interface="popover" :disabled="!content.length" :placeholder = "translate('Select')" slot="end" v-model="fieldMapping['productIdentification']">
<ion-select-option :key="index" v-for="(prop, index) in fileColumns">{{ prop }}</ion-select-option>
</ion-select>
</ion-item>
</template>
</template>
<template v-else>
<ion-select :label="translate(fieldValues.label)" interface="popover" :disabled="!content.length" :placeholder = "translate('Select')" v-model="fieldMapping[field]">
<ion-select-option :key="index" v-for="(prop, index) in fileColumns">{{ prop }}</ion-select-option>
</ion-select>
</template>
</ion-item>

<ion-item-divider>
<ion-label> Optional, or select during review </ion-label>
Expand Down Expand Up @@ -164,6 +171,7 @@ export default defineComponent({
fileColumns: [],
fieldMapping: {},
fields: process.env["VUE_APP_MAPPING_RSTSTK"] ? JSON.parse(process.env["VUE_APP_MAPPING_RSTSTK"]) : {},
identificationTypeId: "SHOPIFY_PROD_SKU",
schedule: '',
isDateTimeModalOpen: false,
shopifyShops: [],
Expand All @@ -172,12 +180,13 @@ export default defineComponent({
selectedShopifyShopId: '',
isUpdateDateTimeModalOpen: false,
shopId: '',
currentJob: {}
currentJob: {},
}
},
computed: {
...mapGetters({
fieldMappings: 'user/getFieldMappings',
goodIdentificationTypes: 'util/getGoodIdentificationTypes',
jobs: 'stock/getScheduledJobs',
productStores: 'util/getProductStores',
userProfile: 'user/getUserProfile'
Expand All @@ -196,6 +205,7 @@ export default defineComponent({
this.$refs.file.value = null;
await this.store.dispatch('stock/fetchJobs')
await this.store.dispatch('util/fetchProductStores')
await this.store.dispatch('util/fetchGoodIdentificationTypes');
},
methods: {
Expand Down Expand Up @@ -338,8 +348,8 @@ export default defineComponent({
return {
quantity: item[this.fieldMapping.restockQuantity],
facilityId: '',
product: item[this.fieldMapping.product],
identificationTypeId: "SHOPIFY_PROD_SKU",
identification: item[this.fieldMapping.productIdentification],
identificationTypeId: this.identificationTypeId,
externalFacilityId: item[this.fieldMapping.facility]
}
})
Expand Down Expand Up @@ -393,7 +403,7 @@ main {
margin: var(--spacer-sm) auto 0;
}
.review{
.review {
margin: var(--spacer-base) var(--spacer-sm);
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/ScheduledRestockReview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export default defineComponent({
return;
}
const groupedItems = Object.keys(this.parsedItems).reduce((result, key) => {
const items = this.parsedItems[key];
const items = this.parsedItems[key].filter(item => item.isSelected);
items.forEach(item => {
if (!result[item.externalFacilityId]) {
result[item.externalFacilityId] = [];
Expand Down

0 comments on commit ef70d89

Please sign in to comment.