Fix lookup for useStatusCodes
This commit is contained in:
parent
87f4245d81
commit
612d71a918
|
|
@ -68,7 +68,9 @@ function renderStatusLabel(
|
|||
);
|
||||
}
|
||||
|
||||
export function getStatusCodes(type: ModelType | string) {
|
||||
export function getStatusCodes(
|
||||
type: ModelType | string
|
||||
): StatusCodeListInterface | null {
|
||||
const statusCodeList = useGlobalStatusState.getState().status;
|
||||
|
||||
if (statusCodeList === undefined) {
|
||||
|
|
|
|||
|
|
@ -31,14 +31,18 @@ export default function useStatusCodes({
|
|||
const statusCodeList = useGlobalStatusState.getState().status;
|
||||
|
||||
const codes = useMemo(() => {
|
||||
const statusCodes = getStatusCodes(modelType) || {};
|
||||
const statusCodes = getStatusCodes(modelType) || null;
|
||||
|
||||
const codesMap: Record<any, any> = {};
|
||||
|
||||
for (const name in statusCodes) {
|
||||
codesMap[name] = statusCodes[name].key;
|
||||
if (!statusCodes) {
|
||||
return codesMap;
|
||||
}
|
||||
|
||||
Object.keys(statusCodes.values).forEach((name) => {
|
||||
codesMap[name] = statusCodes.values[name].key;
|
||||
});
|
||||
|
||||
return codesMap;
|
||||
}, [modelType, statusCodeList]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue