Skip to content

Commit

Permalink
Improved: logic to update default shipping days for facility(#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Nov 20, 2023
1 parent 0884c9b commit 7e77074
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/views/FacilityDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@
</ion-item>
<ion-item lines="full">
<ion-label>{{ translate("Days to ship") }}</ion-label>
<ion-input :value="current.defaultDaysToShip" type="number" min="0" :placeholder="translate('days to ship')"/>
<ion-input v-model="defaultDaysToShip" type="number" min="0" :placeholder="translate('days to ship')"/>
</ion-item>
<ion-button fill="outline" expand="block">
<ion-button fill="outline" expand="block" @click="updateDefaultDaysToShip">
{{ translate("Update days to ship") }}
</ion-button>
</ion-card>
Expand Down Expand Up @@ -466,7 +466,8 @@ export default defineComponent({
return {
isTimeModalOpen: false as boolean,
isLoading: true, // shows whether the facility information fetching is completed or not
segment: 'external-mappings'
segment: 'external-mappings',
defaultDaysToShip: '' // not assinging 0 by default as it will convey the user that the facility can ship same day, but actually defaultDays are not setup on the facility
}
},
computed: {
Expand All @@ -477,6 +478,7 @@ export default defineComponent({
props: ["facilityId"],
async ionViewWillEnter() {
await this.store.dispatch('facility/fetchCurrentFacility', { facilityId: this.facilityId })
this.defaultDaysToShip = this.current.defaultDaysToShip
this.isLoading = false
},
methods: {
Expand Down Expand Up @@ -642,6 +644,25 @@ export default defineComponent({
logger.error('Failed to update fulfillment setting', err)
}
},
async updateDefaultDaysToShip() {
try {
const payload = {
facilityId: this.current.facilityId,
defaultDaysToShip: this.defaultDaysToShip
}
const resp = await FacilityService.updateFacility(payload)
if(!hasError(resp)) {
showToast(translate('Updated default days to ship'))
} else {
throw resp.data
}
} catch(err) {
logger.error('Failed to update default days to ship', err)
showToast(translate('Failed to update default days to ship'))
}
}
},
setup() {
const store = useStore();
Expand Down

0 comments on commit 7e77074

Please sign in to comment.