2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-02 13:28:49 +00:00

made StatusRenderer less strict to allow usage of custom states (#6008)

This commit is contained in:
Matthias Mair 2023-11-30 05:54:45 +01:00 committed by GitHub
parent 0cd66fd16c
commit b343ef337d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -69,7 +69,7 @@ export const StatusRenderer = ({
options options
}: { }: {
status: string; status: string;
type: ModelType; type: ModelType | string;
options?: renderStatusLabelOptionsInterface; options?: renderStatusLabelOptionsInterface;
}) => { }) => {
const statusCodeList = useServerApiState.getState().status; const statusCodeList = useServerApiState.getState().status;

View File

@ -9,7 +9,7 @@ import { ApiPaths } from '../enums/ApiEndpoints';
import { ModelType } from '../enums/ModelType'; import { ModelType } from '../enums/ModelType';
import { ServerAPIProps } from './states'; import { ServerAPIProps } from './states';
type StatusLookup = Record<ModelType, StatusCodeListInterface>; type StatusLookup = Record<ModelType | string, StatusCodeListInterface>;
interface ServerApiStateProps { interface ServerApiStateProps {
server: ServerAPIProps; server: ServerAPIProps;
@ -35,7 +35,8 @@ export const useServerApiState = create<ServerApiStateProps>()(
await api.get(apiUrl(ApiPaths.global_status)).then((response) => { await api.get(apiUrl(ApiPaths.global_status)).then((response) => {
const newStatusLookup: StatusLookup = {} as StatusLookup; const newStatusLookup: StatusLookup = {} as StatusLookup;
for (const key in response.data) { for (const key in response.data) {
newStatusLookup[statusCodeList[key]] = response.data[key].values; newStatusLookup[statusCodeList[key] || key] =
response.data[key].values;
} }
set({ status: newStatusLookup }); set({ status: newStatusLookup });
}); });