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
}: {
status: string;
type: ModelType;
type: ModelType | string;
options?: renderStatusLabelOptionsInterface;
}) => {
const statusCodeList = useServerApiState.getState().status;

View File

@ -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 });
});