Skip to content

Commit

Permalink
Implemneted; Dropdown for productStore & shopifyStore, active review …
Browse files Browse the repository at this point in the history
…page states(hotwax#285)
  • Loading branch information
R-Sourabh committed May 29, 2024
1 parent d144daf commit faba737
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 39 deletions.
9 changes: 9 additions & 0 deletions src/services/UtilService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@ const fetchShopifyShop = async (payload: any): Promise<any> => {
})
}

const fetchProductStores = async (payload: any): Promise<any> => {
return api({
url: "/performFind",
method: "POST",
data: payload
})
}

export const UtilService = {
fetchGoodIdentificationTypes,
fetchShopifyShop,
getFacilities,
getFacilityLocations,
fetchProductStores
}
3 changes: 2 additions & 1 deletion src/store/modules/stock/StockState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default interface StockState {
schedule: {
scheduledTime: string,
shopId: string,
restockName: string
restockName: string ,
productStoreId: string
}
shopifyShops: any,
jobs: any
Expand Down
3 changes: 1 addition & 2 deletions src/store/modules/stock/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ const actions: ActionTree<StockState, RootState> = {
"statusId": "SERVICE_PENDING",
'systemJobEnumId': "JOB_RST_STK",
'systemJobEnumId_op': 'equals',
'orderBy': 'runTime ASC',
'tempExprId_op': 'not-empty'
'orderBy': 'runTime ASC'
},
"noConditionFind": "Y",
"viewSize": 50
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/stock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const orderModule: Module<StockState, RootState> = {
schedule: {
scheduledTime: "",
shopId: "",
restockName: ""
restockName: "",
productStoreId: ""
},
shopifyShops: [],
jobs: {}
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/stock/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const mutations: MutationTree <StockState> = {
state.schedule.scheduledTime = payload.scheduledTime;
state.schedule.shopId = payload.shopId;
state.schedule.restockName = payload.restockName;
state.schedule.productStoreId = payload.productStoreId
},
[types.STOCK_SHOPIFY_SHOPS_UPDATED] (state, payload) {
state.shopifyShops = payload
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/util/UtilState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export default interface UserState {
facilityLocationsByFacilityId: any;
goodIdentificationTypes: [],
isProcessingFile: false,
productStores: []
}
21 changes: 21 additions & 0 deletions src/store/modules/util/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ const actions: ActionTree<UtilState, RootState> = {
}
return state.facilities;
},
async fetchProductStores({ state, commit }) {
let productStores = [];

const payload = {
"viewSize": 50,
"entityName": "ProductStore",
"noConditionFind": "Y"
}
try {
const resp = await UtilService.fetchProductStores(payload);
if (!hasError(resp)) {
productStores = resp.data.docs;
} else {
throw resp.data;
}
} catch (err) {
logger.error(err)
}

commit(types.UTIL_PRODUCT_STORES_UPDATED, productStores);
},
async updateFileProcessingStatus({ commit }, status){
commit(types.UTIL_FILE_PROCESSING_STATUS_UPDATED, { status });
},
Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/util/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const getters: GetterTree <UtilState, RootState> = {
},
getFileProcessingStatus(state) {
return state.isProcessingFile;
},
getProductStores(state) {
return state.productStores;
}

}
export default getters;
3 changes: 2 additions & 1 deletion src/store/modules/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const userModule: Module<UserState, RootState> = {
facilities: [],
facilityLocationsByFacilityId: {},
goodIdentificationTypes: [],
isProcessingFile: false
isProcessingFile: false,
productStores: []
},
getters,
actions,
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/util/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export const UTIL_FACILITIES_UPDATED = SN_UTIL + '/FACILITIES_UPDATED'
export const UTIL_FACILITY_LOCATIONS_BY_FACILITY_ID = SN_UTIL + '/FACILITY_LOCATIONS_BY_FACILITY_ID'
export const UTIL_GOOD_IDENTIFICATION_TYPES_UPDATED = SN_UTIL + '/GOOD_IDENTIFICATION_TYPES_UPDATED'
export const UTIL_FILE_PROCESSING_STATUS_UPDATED = SN_UTIL + '/FILE_PROCESSING_STATUS_UPDATED'

export const UTIL_PRODUCT_STORES_UPDATED = SN_UTIL + '/PRODUCT_STORES_UPDATED'
5 changes: 4 additions & 1 deletion src/store/modules/util/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const mutations: MutationTree <UtilState> = {
},
[types.UTIL_FILE_PROCESSING_STATUS_UPDATED] (state, payload) {
state.isProcessingFile = payload.status;
}
},
[types.UTIL_PRODUCT_STORES_UPDATED] (state, payload) {
state.productStores = payload;
}
}
export default mutations;
2 changes: 1 addition & 1 deletion src/views/Inventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ main {
margin: var(--spacer-sm) auto 0;
}
ion-button{
.review{
margin: var(--spacer-base) var(--spacer-sm);
}
Expand Down
60 changes: 41 additions & 19 deletions src/views/ScheduledRestock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@
</ion-modal>
</ion-item>
<ion-item>
<ion-select label="Shopify store" interface="popover" :placeholder = "translate('Select')" v-model="shopId">
<ion-select :label="translate('Product store')" interface="popover" :value="selectedProductStoreId" @ionChange="updateProductStore($event)">
<ion-select-option v-for="productStore in productStores" :key="productStore.productStoreId" :value="productStore.productStoreId">
{{ productStore.storeName || productStore.productStoreId}}
</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-select :disabled="!selectedProductStoreId" label="Shopify store" interface="popover" :placeholder = "translate('Select')" v-model="selectedShopifyShopId">
<ion-select-option v-for="shop in shopifyShops" :key="shop.shopId">
{{ shop.name ? shop.name : shop.shopId }}
</ion-select-option>
Expand All @@ -74,7 +81,7 @@
</ion-item>
</ion-list>

<ion-button color="medium" expand="block" @click="review()">
<ion-button color="medium" expand="block" class="review" @click="review()">
{{ translate("Review") }}
<ion-icon slot="end" :icon="arrowForwardOutline" />
</ion-button>
Expand Down Expand Up @@ -144,18 +151,19 @@ export default defineComponent({
fileColumns: [],
fieldMapping: {},
fields: process.env["VUE_APP_MAPPING_RSTSTK"] ? JSON.parse(process.env["VUE_APP_MAPPING_RSTSTK"]) : {},
showDateTimePicker: false,
schedule: '',
isDateTimeModalOpen: false,
shopId: '',
shopifyShops: [],
restockName: '',
selectedProductStoreId: '',
selectedShopifyShopId: ''
}
},
computed: {
...mapGetters({
fieldMappings: 'user/getFieldMappings',
jobs: 'stock/getScheduledJobs'
jobs: 'stock/getScheduledJobs',
productStores: 'util/getProductStores'
})
},
mixins:[ parseFileMixin ],
Expand All @@ -168,32 +176,30 @@ export default defineComponent({
}, {})
this.$refs.file.value = null;
await this.store.dispatch('stock/fetchJobs')
await this.store.dispatch('util/fetchProductStores')
},
async mounted() {
await this.fetchShopifyShops()
this.shopId = this.shopifyShops[0]?.shopId
},
methods: {
async fetchShopifyShops() {
async fetchShopifyShops(productStoreId) {
let shopifyShops = []
try {
const resp = await UtilService.fetchShopifyShop({
entityName: "ShopifyShop",
fieldList: ['shopId', 'name'],
noConditionFind: 'Y',
inputFields: {
productStoreId
},
viewSize: 100
})
if (!hasError(resp)) {
this.shopifyShops = resp.data.docs
this.store.dispatch('stock/shopifyShop', this.shopifyShops)
shopifyShops = resp.data.docs
} else {
throw resp.data
}
} catch (error) {
logger.error('Failed to fetch shopify shops.', error)
}
this.shopifyShops = shopifyShops
},
updateTime() {
this.isDateTimeModalOpen = true
Expand Down Expand Up @@ -260,7 +266,17 @@ export default defineComponent({
// showToast(translate("Select all the fields to continue"));
// return;
// }
if(!this.selectedProductStoreId) {
showToast(translate("Please select product store."));
return;
}
if(!this.selectedProductStoreId) {
showToast(translate("Please select shopify shop"));
return;
}
const restockItems = this.content.map(item => {
return {
quantity: item[this.fieldMapping.restockQuantity],
Expand All @@ -274,7 +290,8 @@ export default defineComponent({
console.log('this.schedule', this.schedule)
this.store.dispatch('stock/processUpdateRestockItems', restockItems);
this.store.dispatch('stock/scheduledStock', {
shopId: this.shopId,
productStoreId: this.selectedProductStoreId,
shopId: this.selectedShopifyShopId,
restockName: this.restockName,
scheduledTime: this.schedule ? this.schedule : DateTime.now().toMillis()
})
Expand All @@ -288,6 +305,11 @@ export default defineComponent({
componentProps: { content: this.content, seletedFieldMapping: this.fieldMapping, mappingType: 'RSTSTK'}
});
return createMappingModal.present();
},
updateProductStore(event) {
this.selectedShopifyShopId = ''
this.selectedProductStoreId = event.detail.value;
this.fetchShopifyShops(this.selectedProductStoreId);
}
},
Expand All @@ -313,7 +335,7 @@ main {
margin: var(--spacer-sm) auto 0;
}
ion-button{
.review{
margin: var(--spacer-base) var(--spacer-sm);
}
Expand Down
Loading

0 comments on commit faba737

Please sign in to comment.