Skip to content

Commit

Permalink
Implemented: support for actions configurable on the rules page(#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Jan 18, 2024
1 parent 6750d88 commit 7865bd7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/services/RoutingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const fetchRuleConditions = async (payload: any): Promise<any> => {

const fetchRuleActions = async (payload: any): Promise<any> => {
return api({
url: `rules/${payload.orderRoutingId}/actions`,
url: `rules/${payload.routingRuleId}/actions`,
method: "GET",
query: payload
});
Expand Down
10 changes: 6 additions & 4 deletions src/store/modules/orderRouting/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,20 @@ const actions: ActionTree<OrderRoutingState, RootState> = {
},

async fetchRuleActions({ commit }, routingRuleId) {
let ruleActions = [] as any;
let ruleActions = {} as any;
const payload = {
routingRuleId
}

try {
const resp = await OrderRoutingService.fetchRuleActions(payload);

console.log('actions', resp.data)

if(!hasError(resp) && resp.data.length) {
ruleActions = resp.data
ruleActions = resp.data.reduce((actions: any, action: any) => {
// considering that only one value for an action is available
actions[action.actionTypeEnumId] = action
return actions
}, {})
} else {
throw resp.data
}
Expand Down
38 changes: 24 additions & 14 deletions src/views/BrokeringQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@
<ion-label>{{ "Proximity" }}</ion-label>
<ion-reorder />
</ion-item>
<ion-item>
<!-- TODO: Does not have support for order limit, but need to add this support in future -->
<!-- <ion-item>
<ion-label>{{ "Order limit" }}</ion-label>
<ion-reorder />
</ion-item>
</ion-item> -->
<ion-item>
<ion-label>{{ "Inventory balance" }}</ion-label>
<ion-reorder />
Expand Down Expand Up @@ -160,25 +161,25 @@
<ion-label>{{ "Unavailable items" }}</ion-label>
</ion-item>
<ion-item lines="none">
<ion-select label="Move items to" interface="popover">
<ion-select-option value="next">
<ion-select label="Move items to" interface="popover" :value="getRuleActionType()">
<ion-select-option :value="actionEnums['NEXT_RULE'].id">
{{ "Next rule" }}
<ion-icon :icon="playForwardOutline"/>
</ion-select-option>
<ion-select-option value="queue">
<ion-select-option :value="actionEnums['MOVE_TO_QUEUE'].id">
{{ "Queue" }}
<ion-icon :icon="golfOutline"/>
</ion-select-option>
</ion-select>
</ion-item>
<ion-item lines="none">
<ion-item lines="none" v-show="getRuleActionType() === actionEnums['MOVE_TO_QUEUE'].id">
<ion-select label="Queue" interface="popover">
<ion-select-option>{{ "Next rule" }}</ion-select-option>
<ion-select-option>{{ "Queue" }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item lines="none">
<ion-label>{{ "Auto cancel days" }}</ion-label>
<ion-chip outline>{{ "10 days" }}</ion-chip>
<ion-chip outline>{{ ruleActions[actionEnums['AUTO_CANCEL_DAYS'].id]?.actionValue }}{{ ' days' }}</ion-chip>
</ion-item>
</ion-card>
</div>
Expand All @@ -203,22 +204,24 @@ const props = defineProps({
orderRoutingId: {
type: String,
required: true
},
routingGroupId: {
type: String,
requied: true
}
})
const enums = JSON.parse(process.env?.VUE_APP_RULE_ENUMS as string)
const actionEnums = JSON.parse(process.env?.VUE_APP_RULE_ACTION_ENUMS as string)
const currentRouting = computed(() => store.getters["orderRouting/getCurrentOrderRouting"])
const routingRules = computed(() => store.getters["orderRouting/getRoutingRules"])
const routingFilters = computed(() => store.getters["orderRouting/getCurrentRouteFilters"])
const ruleActions = computed(() => store.getters["orderRouting/getRuleActions"])
onIonViewWillEnter(async () => {
await store.dispatch("orderRouting/fetchRoutingRules", props.orderRoutingId)
await store.dispatch("orderRouting/fetchRoutingFilters", props.orderRoutingId)
console.log('this.rules before', JSON.parse(JSON.stringify(routingRules.value)))

Check warning on line 219 in src/views/BrokeringQuery.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

Unexpected console statement

Check warning on line 219 in src/views/BrokeringQuery.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

Unexpected console statement
await Promise.all([store.dispatch("orderRouting/fetchRoutingRules", props.orderRoutingId), store.dispatch("orderRouting/fetchRoutingFilters", props.orderRoutingId)])
if(routingRules.value.length) {
await Promise.all([store.dispatch("orderRouting/fetchRuleConditions", routingRules.value[0].routingRuleId), store.dispatch("orderRouting/fetchRuleActions", routingRules.value[0].routingRuleId)])
}
})
async function addInventoryFilterOptions() {
Expand Down Expand Up @@ -260,6 +263,13 @@ async function addInventoryRule() {
return newRuleAlert.present();
}
function getRuleActionType() {
const actionTypes = ["ORA_NEXT_RULE", "ORA_MV_TO_QUEUE"]
return Object.keys(ruleActions.value).find((actionId: string) => {
return actionTypes.includes(actionId)
})
}
</script>

<style scoped>
Expand Down

0 comments on commit 7865bd7

Please sign in to comment.