2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-10 13:51:01 +00:00

Fix for status table filters

This commit is contained in:
Oliver Walters
2024-11-21 13:21:26 +00:00
parent 80d6a97e1f
commit d1e045017a
2 changed files with 11 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ import type { ModelType } from '../enums/ModelType';
import { apiUrl } from './ApiState'; import { apiUrl } from './ApiState';
import { useUserState } from './UserState'; import { useUserState } from './UserState';
type StatusLookup = Record<ModelType | string, StatusCodeListInterface>; export type StatusLookup = Record<ModelType | string, StatusCodeListInterface>;
interface ServerStateProps { interface ServerStateProps {
status?: StatusLookup; status?: StatusLookup;

View File

@@ -1,7 +1,11 @@
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import type {
StatusCodeInterface,
StatusCodeListInterface
} from '../components/render/StatusRenderer';
import type { ModelType } from '../enums/ModelType'; import type { ModelType } from '../enums/ModelType';
import { useGlobalStatusState } from '../states/StatusState'; import { type StatusLookup, useGlobalStatusState } from '../states/StatusState';
/** /**
* Interface for the table filter choice * Interface for the table filter choice
@@ -70,17 +74,18 @@ export function StatusFilterOptions(
model: ModelType model: ModelType
): () => TableFilterChoice[] { ): () => TableFilterChoice[] {
return () => { return () => {
const statusCodeList = useGlobalStatusState.getState().status; const statusCodeList: StatusLookup | undefined =
useGlobalStatusState.getState().status;
if (!statusCodeList) { if (!statusCodeList) {
return []; return [];
} }
const codes = statusCodeList[model]; const codes: StatusCodeListInterface | undefined = statusCodeList[model];
if (codes) { if (codes) {
return Object.keys(codes).map((key) => { return Object.keys(codes.values).map((key) => {
const entry = codes[key]; const entry: StatusCodeInterface = codes.values[key];
return { return {
value: entry.key.toString(), value: entry.key.toString(),
label: entry.label?.toString() ?? entry.key.toString() label: entry.label?.toString() ?? entry.key.toString()