Client: Typing for spool and vendor useTable

This commit is contained in:
Donkie
2023-07-06 16:41:25 +02:00
parent 096f75ffb5
commit 2b33f73b28
4 changed files with 7 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ import dayjs from "dayjs";
import utc from "dayjs/plugin/utc"; import utc from "dayjs/plugin/utc";
import { genericSorter } from "../../utils/sorting"; import { genericSorter } from "../../utils/sorting";
import { SortOrder } from "antd/es/table/interface"; import { SortOrder } from "antd/es/table/interface";
import { ISpool } from "./model";
dayjs.extend(utc); dayjs.extend(utc);
@@ -38,7 +39,7 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
}); });
// Fetch data from the API // Fetch data from the API
const { tableProps, sorters } = useTable({ const { tableProps, sorters } = useTable<ISpool>({
syncWithLocation: false, syncWithLocation: false,
pagination: { pagination: {
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work. mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
@@ -62,7 +63,7 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
// Add a filament_name field to the dataSource // Add a filament_name field to the dataSource
dataSource.forEach((element) => { dataSource.forEach((element) => {
if ("vendor" in element.filament) { if (element.filament.vendor && "name" in element.filament.vendor) {
element.filament_name = `${element.filament.vendor.name} - ${element.filament.name}`; element.filament_name = `${element.filament.vendor.name} - ${element.filament.name}`;
} else { } else {
element.filament_name = element.filament.name; element.filament_name = element.filament.name;

View File

@@ -11,4 +11,5 @@ export interface ISpool {
location?: string; location?: string;
lot_nr?: string; lot_nr?: string;
comment?: string; comment?: string;
[key: string]: unknown;
} }

View File

@@ -17,6 +17,7 @@ import dayjs from "dayjs";
import utc from "dayjs/plugin/utc"; import utc from "dayjs/plugin/utc";
import { genericSorter } from "../../utils/sorting"; import { genericSorter } from "../../utils/sorting";
import { SortOrder } from "antd/es/table/interface"; import { SortOrder } from "antd/es/table/interface";
import { IVendor } from "./model";
dayjs.extend(utc); dayjs.extend(utc);
@@ -36,7 +37,7 @@ export const VendorList: React.FC<IResourceComponentsProps> = () => {
}); });
// Fetch data from the API // Fetch data from the API
const { tableProps, sorters } = useTable({ const { tableProps, sorters } = useTable<IVendor>({
syncWithLocation: false, syncWithLocation: false,
pagination: { pagination: {
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work. mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.

View File

@@ -3,4 +3,5 @@ export interface IVendor {
registered: string; registered: string;
name: string; name: string;
comment?: string; comment?: string;
[key: string]: unknown;
} }