-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented: support to fetch the enums based on parentType
Fetching enums with parentType ORDER_ROUTING Improved type for enums state Fetching enums on the initial load of runs page
- Loading branch information
1 parent
f043448
commit 7875b9a
Showing
6 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import api from "@/api" | ||
|
||
const fetchEnums = async (payload: any): Promise<any> => { | ||
return api({ | ||
url: "enums", | ||
method: "GET", | ||
params: payload | ||
}); | ||
} | ||
|
||
export const UtilService = { | ||
fetchEnums | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { Enumeration } from "@/types"; | ||
|
||
export default interface UtilState { | ||
enums: Array<Enumeration> | ||
enums: { | ||
[key: string]: { | ||
[key: string]: Enumeration | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
import { ActionTree } from "vuex" | ||
import RootState from "@/store/RootState" | ||
import UtilState from "./UtilState" | ||
import logger from "@/logger" | ||
import { hasError } from "@/utils" | ||
import * as types from "./mutation-types" | ||
import { UtilService } from "@/services/UtilService" | ||
import { EnumerationAndType } from "@/types" | ||
|
||
const actions: ActionTree<UtilState, RootState> = {} | ||
const actions: ActionTree<UtilState, RootState> = { | ||
async fetchEnums({ commit }, payload) { | ||
let enums = {} | ||
|
||
try { | ||
const resp = await UtilService.fetchEnums(payload); | ||
|
||
if(!hasError(resp) && resp.data.length) { | ||
enums = resp.data.reduce((enumerations: any, data: EnumerationAndType) => { | ||
if(enumerations[data.enumTypeId]) { | ||
enumerations[data.enumTypeId][data.enumId] = data | ||
} else { | ||
enumerations[data.enumTypeId] = { | ||
[data.enumId]: data | ||
} | ||
} | ||
return enumerations | ||
}, {}) | ||
} | ||
} catch(err) { | ||
logger.error('error', err) | ||
} | ||
|
||
commit(types.UTIL_ENUMS_UPDATED, enums) | ||
} | ||
} | ||
|
||
export default actions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters