Skip to content

Commit

Permalink
Improved: icon for selecting store for item, added state variable for…
Browse files Browse the repository at this point in the history
… cancellation setting and dynamic text on ui based on cancellation settings (hotwax#92)
  • Loading branch information
amansinghbais committed Nov 28, 2024
1 parent 6a7fcfe commit 1a6d36c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export default interface UserState {
deliveryMethod: string;
permissions: any;
isSplitEnabled: boolean;
isCancellationAllowed: boolean;
}
2 changes: 2 additions & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ const actions: ActionTree<UserState, RootState> = {
const permissions = resp.data.docs.filter((permission: any) => permission.settingValue == 'true').map((permission: any) => permission.settingTypeEnumId)
const deliveryMethod = resp.data.docs.find((permission: any) => permission.settingTypeEnumId === 'RF_SHIPPING_METHOD')?.settingValue
const isSplitEnabled = resp.data.docs.find((permission: any) => permission.settingTypeEnumId === 'CUST_ORD_ITEM_SPLIT')?.settingValue
const isCancellationAllowed = resp.data.docs.find((permission: any) => permission.settingTypeEnumId === 'CUST_ALLOW_CNCL')?.settingValue
const appPermissions = prepareAppPermissions(permissions);
setPermissions(appPermissions);
commit(types.USER_DELIVERY_METHOD_UPDATED, deliveryMethod ? deliveryMethod : "STANDARD");
commit(types.USER_PERMISSIONS_UPDATED, appPermissions);
commit(types.USER_ORDER_SPLIT_CONFIG_UPDATED, isSplitEnabled === "true");
commit(types.USER_ITEM_CANCELLATION_CONFIG_UPDATED, isCancellationAllowed === "true");
}
} catch (error) {
console.error(error)
Expand Down
3 changes: 3 additions & 0 deletions src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const getters: GetterTree <UserState, RootState> = {
},
isSplitEnabled (state) {
return state.isSplitEnabled;
},
isCancellationAllowed (state) {
return state.isCancellationAllowed
}
}
export default getters;
3 changes: 2 additions & 1 deletion src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const userModule: Module<UserState, RootState> = {
instanceUrl: '',
deliveryMethod: '',
permissions: [],
isSplitEnabled: false
isSplitEnabled: false,
isCancellationAllowed: false
},
getters,
actions,
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED'
export const USER_PERMISSIONS_UPDATED = SN_USER + '/PERMISSIONS_UPDATED'
export const USER_DELIVERY_METHOD_UPDATED = SN_USER + '/DELIVERY_METHOD_UPDATED'
export const USER_ORDER_SPLIT_CONFIG_UPDATED = SN_USER + '/ORDER_SPLIT_CONFIG_UPDATED'
export const USER_ITEM_CANCELLATION_CONFIG_UPDATED = SN_USER + '/ITEM_CANCELLATION_CONFIG_UPDATED'
3 changes: 3 additions & 0 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const mutations: MutationTree <UserState> = {
},
[types.USER_ORDER_SPLIT_CONFIG_UPDATED] (state, payload) {
state.isSplitEnabled = payload
},
[types.USER_ITEM_CANCELLATION_CONFIG_UPDATED] (state, payload) {
state.isCancellationAllowed = payload
}
}
export default mutations;
9 changes: 6 additions & 3 deletions src/views/Order.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<Image :src='getProduct(item.productId).mainImageUrl' />
</ion-thumbnail>
<ion-label>
<p class="overline" v-if="item.isItemCancelled">{{ translate("Request Cancellation") }}</p>
<p class="overline" v-if="item.isItemCancelled">{{ translate(isCancellationAllowed ? "Cancel" : "Request Cancellation") }}</p>
{{ item.name }}
<p v-for="(attribute, feature) in ($filters.groupFeatures(getProduct(item.productId).featureHierarchy))" :key="attribute" >
<span class="sentence-case">{{ feature }}</span>: {{ attribute }}
Expand All @@ -73,6 +73,7 @@
</ion-chip>
<ion-button v-else slot="end" fill="clear" @click="updatePickupLocation(false, item.selectedFacilityId, item)">
<ion-icon :icon="addOutline" slot="icon-only" />
<ion-icon :icon="storefrontOutline" slot="icon-only" />
</ion-button>
</template>
</ion-item>
Expand All @@ -89,7 +90,7 @@
<Image :src='getProduct(item.productId).mainImageUrl' />
</ion-thumbnail>
<ion-label>
<p class="overline" v-if="item.isItemCancelled">{{ translate("Request Cancellation") }}</p>
<p class="overline" v-if="item.isItemCancelled">{{ translate(isCancellationAllowed ? "Cancel" :"Request Cancellation") }}</p>
{{ item.name }}
<p v-for="(attribute, feature) in ($filters.groupFeatures(getProduct(item.productId).featureHierarchy))" :key="attribute" >
<span class="sentence-case">{{ feature }}</span>: {{ attribute }}
Expand Down Expand Up @@ -150,7 +151,7 @@

<div class="actions">
<ion-button :disabled="!isOrderItemsEligibleForUpdation(order.shipGroup)" @click="confirmSave(order.shipGroup)" fill="clear">{{ translate("Save changes") }}</ion-button>
<ion-button v-if="hasPermission(Actions.APP_SHPGRP_CNCL)" @click="cancelOrder(order.shipGroup)" fill="clear" color="danger">{{ translate("Cancel") }}</ion-button>
<ion-button @click="cancelOrder(order.shipGroup)" fill="clear" color="danger">{{ translate(isCancellationAllowed ? "Cancel" : "Request cancel") }}</ion-button>
</div>
</ion-card>
<div v-else-if="isOrderUpdated" class="ion-text-center ion-padding-top">
Expand Down Expand Up @@ -256,6 +257,7 @@ export default defineComponent({
...mapGetters({
deliveryMethod: 'user/getDeliveryMethod',
isSplitEnabled: 'user/isSplitEnabled',
isCancellationAllowed: 'user/isCancellationAllowed'
})
},
props: ["token"],
Expand Down Expand Up @@ -556,6 +558,7 @@ export default defineComponent({
{
text: translate("Cancel"),
handler: async () => {
// Todo: handle case for the request cancellation
const isCancelled = await this.cancelShipGroup(shipGroup, []);
showToast(translate(isCancelled ? "Order cancelled successfully." : "Failed to cancel the order."))
}
Expand Down
11 changes: 9 additions & 2 deletions src/views/PickupLocationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<ion-radio-group v-model="selectedFacilityIdValue">
<ion-item lines="none" v-if="!isPickupForAll">
<ion-radio label-placement="end" value="cancel">
<ion-label>{{ translate("Request cancelation") }}</ion-label>
<ion-label>{{ translate(isCancellationAllowed ? "Cancel item" : "Request cancelation") }}</ion-label>
</ion-radio>
</ion-item>

Expand Down Expand Up @@ -83,8 +83,8 @@ import {
import { defineComponent } from 'vue';
import { closeOutline, locationOutline } from 'ionicons/icons';
import { useRouter } from "vue-router";
import { useStore } from "@/store";
import { translate } from '@/i18n';
import { mapGetters, useStore } from 'vuex'
export default defineComponent({
name: 'PickupLocationModal',
Expand Down Expand Up @@ -114,6 +114,13 @@ export default defineComponent({
}
},
props: ["nearbyStores", "isPickupForAll", "availableStores", "storesWithInventory", "selectedFacilityId", "currentProductId", "customerAddress"],
computed: {
...mapGetters({
deliveryMethod: 'user/getDeliveryMethod',
isSplitEnabled: 'user/isSplitEnabled',
isCancellationAllowed: 'user/isCancellationAllowed'
})
},
async mounted() {
if(this.isPickupForAll) {
this.stores = this.nearbyStores
Expand Down

0 comments on commit 1a6d36c

Please sign in to comment.