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:
@@ -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;
|
||||||
|
@@ -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()
|
||||||
|
Reference in New Issue
Block a user