Client: Improved the lists a bit

This commit is contained in:
Donkie
2023-05-16 21:50:09 +02:00
parent 9a063fcf5d
commit 166c6fa0d1
2 changed files with 75 additions and 38 deletions

View File

@@ -7,6 +7,7 @@ import {
ShowButton,
DateField,
NumberField,
TextField,
} from "@refinedev/antd";
import { Table, Space } from "antd";
@@ -15,30 +16,58 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
syncWithLocation: true,
});
tableProps.dataSource?.forEach((element) => {
if ("vendor" in element.filament) {
element.filament_name = `${element.filament.vendor.name} - ${element.filament.name}`;
} else {
element.filament_name = element.filament.name;
}
});
return (
<List>
<Table {...tableProps} rowKey="id">
<Table.Column dataIndex="id" title="Id" />
<Table.Column dataIndex="filament_name" title="Filament" />
<Table.Column
dataIndex={["filament", "vendor", "name"]}
title="Vendor"
dataIndex="used_weight"
title="Used Weight"
render={(value) => {
return (
<NumberField
value={value}
options={{
unitDisplay: "short",
unit: "gram",
style: "unit",
maximumFractionDigits: 1,
}}
/>
);
}}
/>
<Table.Column dataIndex={["filament", "name"]} title="Filament Name" />
<Table.Column
dataIndex="remaining_weight"
title="Estimated Remaining Weight"
render={(value) => (
<NumberField
value={value}
options={{
unitDisplay: "short",
unit: "gram",
style: "unit",
maximumFractionDigits: 1,
}}
/>
)}
render={(value) => {
if (value === null || value === undefined) {
return <TextField value="Unknown" />;
}
return (
<NumberField
value={Math.max(value, 0)}
options={{
unitDisplay: "short",
unit: "gram",
style: "unit",
maximumFractionDigits: 1,
}}
/>
);
}}
/>
<Table.Column dataIndex="location" title="Location" />
<Table.Column dataIndex="lot_nr" title="Lot Nr" />
<Table.Column
dataIndex={["first_used"]}
title="First Used"
@@ -53,8 +82,6 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
<DateField value={value} format="YYYY-MM-DD HH:mm:ss" />
)}
/>
<Table.Column dataIndex="location" title="Location" />
<Table.Column dataIndex="lot_nr" title="Lot Nr" />
<Table.Column dataIndex={["comment"]} title="Comment" />
<Table.Column
title="Actions"