mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-08 11:16:25 +00:00
Fix for status table filters
This commit is contained in:
1 parent
80d6a97e1f
commit
d1e045017a
2 files changed
+11
-6
No files matched your search
@@ -9,7 +9,7 @@ import type { ModelType } from '../enums/ModelType';
|
||||
import { apiUrl } from './ApiState';
|
||||
import { useUserState } from './UserState';
|
||||
|
||||
type StatusLookup = Record<ModelType | string, StatusCodeListInterface>;
|
||||
export type StatusLookup = Record<ModelType | string, StatusCodeListInterface>;
|
||||
|
||||
interface ServerStateProps {
|
||||
status?: StatusLookup;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { t } from '@lingui/macro';
|
||||
|
||||
import type {
|
||||
StatusCodeInterface,
|
||||
StatusCodeListInterface
|
||||
} from '../components/render/StatusRenderer';
|
||||
import type { ModelType } from '../enums/ModelType';
|
||||
import { useGlobalStatusState } from '../states/StatusState';
|
||||
import { type StatusLookup, useGlobalStatusState } from '../states/StatusState';
|
||||
|
||||
/**
|
||||
* Interface for the table filter choice
|
||||
@@ -70,17 +74,18 @@ export function StatusFilterOptions(
|
||||
model: ModelType
|
||||
): () => TableFilterChoice[] {
|
||||
return () => {
|
||||
const statusCodeList = useGlobalStatusState.getState().status;
|
||||
const statusCodeList: StatusLookup | undefined =
|
||||
useGlobalStatusState.getState().status;
|
||||
|
||||
if (!statusCodeList) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const codes = statusCodeList[model];
|
||||
const codes: StatusCodeListInterface | undefined = statusCodeList[model];
|
||||
|
||||
if (codes) {
|
||||
return Object.keys(codes).map((key) => {
|
||||
const entry = codes[key];
|
||||
return Object.keys(codes.values).map((key) => {
|
||||
const entry: StatusCodeInterface = codes.values[key];
|
||||
return {
|
||||
value: entry.key.toString(),
|
||||
label: entry.label?.toString() ?? entry.key.toString()
|
||||
|
||||
Reference in new issue
Block a user