diff --git a/src/frontend/src/pages/part/pricing/SaleHistoryPanel.tsx b/src/frontend/src/pages/part/pricing/SaleHistoryPanel.tsx index 7a8b823866..d6054994d5 100644 --- a/src/frontend/src/pages/part/pricing/SaleHistoryPanel.tsx +++ b/src/frontend/src/pages/part/pricing/SaleHistoryPanel.tsx @@ -18,6 +18,7 @@ import { ApiEndpoints } from '../../../enums/ApiEndpoints'; import { useTable } from '../../../hooks/UseTable'; import { apiUrl } from '../../../states/ApiState'; import { TableColumn } from '../../../tables/Column'; +import { DateColumn } from '../../../tables/ColumnRenderers'; import { InvenTreeTable } from '../../../tables/InvenTreeTable'; import { NoPricingData } from './PricingPanel'; @@ -40,13 +41,12 @@ export default function SaleHistoryPanel({ part }: { part: any }): ReactNode { switchable: true, render: (record: any) => record?.customer_detail?.name }, - { - accessor: 'shipment_date', + DateColumn({ + accessor: 'order_detail.shipment_date', title: t`Date`, sortable: false, - switchable: true, - render: (record: any) => renderDate(record.order_detail.shipment_date) - }, + switchable: true + }), { accessor: 'sale_price', title: t`Sale Price`, diff --git a/src/frontend/src/tables/ColumnRenderers.tsx b/src/frontend/src/tables/ColumnRenderers.tsx index 04e3a10b03..83cfdf0884 100644 --- a/src/frontend/src/tables/ColumnRenderers.tsx +++ b/src/frontend/src/tables/ColumnRenderers.tsx @@ -191,9 +191,11 @@ export function DateColumn({ accessor, sortable, switchable, + ordering, title }: { accessor?: string; + ordering?: string; sortable?: boolean; switchable?: boolean; title?: string; @@ -201,9 +203,10 @@ export function DateColumn({ return { accessor: accessor ?? 'date', sortable: sortable ?? true, + ordering: ordering, title: title ?? t`Date`, switchable: switchable, - render: (record: any) => renderDate(record[accessor ?? 'date']) + render: (record: any) => renderDate(resolveItem(record, accessor ?? 'date')) }; } diff --git a/src/frontend/src/tables/build/BuildOrderTable.tsx b/src/frontend/src/tables/build/BuildOrderTable.tsx index 405909cfca..34ff1c14a5 100644 --- a/src/frontend/src/tables/build/BuildOrderTable.tsx +++ b/src/frontend/src/tables/build/BuildOrderTable.tsx @@ -17,6 +17,7 @@ import { useUserState } from '../../states/UserState'; import { TableColumn } from '../Column'; import { CreationDateColumn, + DateColumn, ProjectCodeColumn, ReferenceColumn, ResponsibleColumn, @@ -62,11 +63,10 @@ function buildOrderTableColumns(): TableColumn[] { }, CreationDateColumn(), TargetDateColumn(), - { + DateColumn({ accessor: 'completion_date', - sortable: true, - render: (record: any) => renderDate(record.completion_date) - }, + sortable: true + }), { accessor: 'issued_by', sortable: true, diff --git a/src/frontend/src/tables/stock/StockItemTable.tsx b/src/frontend/src/tables/stock/StockItemTable.tsx index 69295942c2..818620e217 100644 --- a/src/frontend/src/tables/stock/StockItemTable.tsx +++ b/src/frontend/src/tables/stock/StockItemTable.tsx @@ -206,18 +206,12 @@ function stockItemTableColumns(): TableColumn[] { title: t`Stocktake`, sortable: true }), - { - accessor: 'expiry_date', - sortable: true, - switchable: true, - render: (record: any) => renderDate(record.expiry_date) - }, - { - accessor: 'updated', - sortable: true, - switchable: true, - render: (record: any) => renderDate(record.updated) - }, + DateColumn({ + accessor: 'expiry_date' + }), + DateColumn({ + accessor: 'updated' + }), // TODO: purchase order // TODO: Supplier part {