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:
parent
0cd66fd16c
commit
b343ef337d
@ -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;
|
||||||
|
@ -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 });
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user