mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
made StatusRenderer less strict to allow usage of custom states (#6008)
This commit is contained in:
parent
0cd66fd16c
commit
b343ef337d
@ -69,7 +69,7 @@ export const StatusRenderer = ({
|
||||
options
|
||||
}: {
|
||||
status: string;
|
||||
type: ModelType;
|
||||
type: ModelType | string;
|
||||
options?: renderStatusLabelOptionsInterface;
|
||||
}) => {
|
||||
const statusCodeList = useServerApiState.getState().status;
|
||||
|
@ -9,7 +9,7 @@ import { ApiPaths } from '../enums/ApiEndpoints';
|
||||
import { ModelType } from '../enums/ModelType';
|
||||
import { ServerAPIProps } from './states';
|
||||
|
||||
type StatusLookup = Record<ModelType, StatusCodeListInterface>;
|
||||
type StatusLookup = Record<ModelType | string, StatusCodeListInterface>;
|
||||
|
||||
interface ServerApiStateProps {
|
||||
server: ServerAPIProps;
|
||||
@ -35,7 +35,8 @@ export const useServerApiState = create<ServerApiStateProps>()(
|
||||
await api.get(apiUrl(ApiPaths.global_status)).then((response) => {
|
||||
const newStatusLookup: StatusLookup = {} as StatusLookup;
|
||||
for (const key in response.data) {
|
||||
newStatusLookup[statusCodeList[key]] = response.data[key].values;
|
||||
newStatusLookup[statusCodeList[key] || key] =
|
||||
response.data[key].values;
|
||||
}
|
||||
set({ status: newStatusLookup });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user