Skip to content

Commit

Permalink
[PUI]: Refactor columns
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Apr 29, 2024
1 parent 0c573d7 commit 0ee42d3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/frontend/src/pages/part/pricing/SaleHistoryPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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`,
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/src/tables/ColumnRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,22 @@ export function DateColumn({
accessor,
sortable,
switchable,
ordering,
title
}: {
accessor?: string;
ordering?: string;
sortable?: boolean;
switchable?: boolean;
title?: string;
}): TableColumn {
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'))
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/frontend/src/tables/build/BuildOrderTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useUserState } from '../../states/UserState';
import { TableColumn } from '../Column';
import {
CreationDateColumn,
DateColumn,
ProjectCodeColumn,
ReferenceColumn,
ResponsibleColumn,
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 6 additions & 12 deletions src/frontend/src/tables/stock/StockItemTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 0ee42d3

Please sign in to comment.