Skip to content

Commit

Permalink
Filter StockTrackingTable by user
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Sep 30, 2024
1 parent e9640f4 commit 1f8f624
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/frontend/src/tables/stock/StockTrackingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import {
import { RenderUser } from '../../components/render/User';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType';
import { useUserFilters } from '../../hooks/UseFilter';
import { useTable } from '../../hooks/UseTable';
import { apiUrl } from '../../states/ApiState';
import { TableColumn } from '../Column';
import { DateColumn, DescriptionColumn } from '../ColumnRenderers';
import { TableFilter } from '../Filter';
import { InvenTreeTable } from '../InvenTreeTable';

type StockTrackingEntry = {
Expand All @@ -35,6 +37,8 @@ export function StockTrackingTable({ itemId }: Readonly<{ itemId: number }>) {
const navigate = useNavigate();
const table = useTable('stock_tracking');

const userFilters = useUserFilters();

// Render "details" for a stock tracking record
const renderDetails = useCallback(
(record: any) => {
Expand Down Expand Up @@ -170,6 +174,17 @@ export function StockTrackingTable({ itemId }: Readonly<{ itemId: number }>) {
[navigate]
);

const filters: TableFilter[] = useMemo(() => {
return [
{
name: 'user',
label: t`User`,
choices: userFilters.choices,
description: t`Filter by user`
}
];
}, [userFilters]);

const tableColumns: TableColumn[] = useMemo(() => {
return [
DateColumn({
Expand Down Expand Up @@ -214,7 +229,8 @@ export function StockTrackingTable({ itemId }: Readonly<{ itemId: number }>) {
item: itemId,
user_detail: true
},
enableDownload: true
enableDownload: true,
tableFilters: filters
}}
/>
);
Expand Down

0 comments on commit 1f8f624

Please sign in to comment.