Client: Reformatted all files with new line length
This commit is contained in:
@@ -11,9 +11,7 @@ interface CreateOrCloneProps {
|
||||
mode: "create" | "clone";
|
||||
}
|
||||
|
||||
export const FilamentCreate: React.FC<
|
||||
IResourceComponentsProps & CreateOrCloneProps
|
||||
> = (props) => {
|
||||
export const FilamentCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps> = (props) => {
|
||||
const t = useTranslate();
|
||||
|
||||
const { formProps, saveButtonProps, formLoading } = useForm<IFilament>();
|
||||
@@ -96,12 +94,7 @@ export const FilamentCreate: React.FC<
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
precision={2}
|
||||
formatter={numberFormatter}
|
||||
parser={numberParser}
|
||||
/>
|
||||
<InputNumber min={0} precision={2} formatter={numberFormatter} parser={numberParser} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("filament.fields.density")}
|
||||
@@ -112,13 +105,7 @@ export const FilamentCreate: React.FC<
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
addonAfter="g/cm³"
|
||||
precision={3}
|
||||
formatter={numberFormatter}
|
||||
parser={numberParser}
|
||||
/>
|
||||
<InputNumber min={0} addonAfter="g/cm³" precision={3} formatter={numberFormatter} parser={numberParser} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("filament.fields.diameter")}
|
||||
@@ -129,13 +116,7 @@ export const FilamentCreate: React.FC<
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
addonAfter="mm"
|
||||
precision={2}
|
||||
formatter={numberFormatter}
|
||||
parser={numberParser}
|
||||
/>
|
||||
<InputNumber min={0} addonAfter="mm" precision={2} formatter={numberFormatter} parser={numberParser} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("filament.fields.weight")}
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import React from "react";
|
||||
import { IResourceComponentsProps, useTranslate } from "@refinedev/core";
|
||||
import { Edit, useForm, useSelect } from "@refinedev/antd";
|
||||
import {
|
||||
Form,
|
||||
Input,
|
||||
DatePicker,
|
||||
Select,
|
||||
InputNumber,
|
||||
ColorPicker,
|
||||
} from "antd";
|
||||
import { Form, Input, DatePicker, Select, InputNumber, ColorPicker } from "antd";
|
||||
import dayjs from "dayjs";
|
||||
import TextArea from "antd/es/input/TextArea";
|
||||
import { numberFormatter, numberParser } from "../../utils/parsing";
|
||||
@@ -26,8 +19,7 @@ export const FilamentEdit: React.FC<IResourceComponentsProps> = () => {
|
||||
});
|
||||
|
||||
if (formProps.initialValues) {
|
||||
formProps.initialValues["vendor_id"] =
|
||||
formProps.initialValues["vendor"]?.id;
|
||||
formProps.initialValues["vendor_id"] = formProps.initialValues["vendor"]?.id;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -124,12 +116,7 @@ export const FilamentEdit: React.FC<IResourceComponentsProps> = () => {
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
precision={2}
|
||||
formatter={numberFormatter}
|
||||
parser={numberParser}
|
||||
/>
|
||||
<InputNumber min={0} precision={2} formatter={numberFormatter} parser={numberParser} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("filament.fields.density")}
|
||||
@@ -140,13 +127,7 @@ export const FilamentEdit: React.FC<IResourceComponentsProps> = () => {
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
addonAfter="g/cm³"
|
||||
precision={3}
|
||||
formatter={numberFormatter}
|
||||
parser={numberParser}
|
||||
/>
|
||||
<InputNumber min={0} addonAfter="g/cm³" precision={3} formatter={numberFormatter} parser={numberParser} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("filament.fields.diameter")}
|
||||
@@ -157,13 +138,7 @@ export const FilamentEdit: React.FC<IResourceComponentsProps> = () => {
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
addonAfter="mm"
|
||||
precision={2}
|
||||
formatter={numberFormatter}
|
||||
parser={numberParser}
|
||||
/>
|
||||
<InputNumber min={0} addonAfter="mm" precision={2} formatter={numberFormatter} parser={numberParser} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("filament.fields.weight")}
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
import React from "react";
|
||||
import {
|
||||
IResourceComponentsProps,
|
||||
BaseRecord,
|
||||
useTranslate,
|
||||
} from "@refinedev/core";
|
||||
import {
|
||||
useTable,
|
||||
List,
|
||||
EditButton,
|
||||
ShowButton,
|
||||
CloneButton,
|
||||
} from "@refinedev/antd";
|
||||
import { IResourceComponentsProps, BaseRecord, useTranslate } from "@refinedev/core";
|
||||
import { useTable, List, EditButton, ShowButton, CloneButton } from "@refinedev/antd";
|
||||
import { Table, Space, Button, Dropdown } from "antd";
|
||||
import dayjs from "dayjs";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
@@ -18,18 +8,8 @@ import { IFilament } from "./model";
|
||||
import { genericSorter, typeSorters } from "../../utils/sorting";
|
||||
import { genericFilterer, typeFilters } from "../../utils/filtering";
|
||||
import { EditOutlined, FilterOutlined } from "@ant-design/icons";
|
||||
import {
|
||||
TableState,
|
||||
useInitialTableState,
|
||||
useStoreInitialState,
|
||||
} from "../../utils/saveload";
|
||||
import {
|
||||
DateColumn,
|
||||
FilteredColumn,
|
||||
NumberColumn,
|
||||
SortedColumn,
|
||||
SpoolIconColumn,
|
||||
} from "../../components/column";
|
||||
import { TableState, useInitialTableState, useStoreInitialState } from "../../utils/saveload";
|
||||
import { DateColumn, FilteredColumn, NumberColumn, SortedColumn, SpoolIconColumn } from "../../components/column";
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
@@ -44,32 +24,23 @@ export const FilamentList: React.FC<IResourceComponentsProps> = () => {
|
||||
const initialState = useInitialTableState("filamentList");
|
||||
|
||||
// Fetch data from the API
|
||||
const {
|
||||
tableProps,
|
||||
sorters,
|
||||
setSorters,
|
||||
filters,
|
||||
setFilters,
|
||||
current,
|
||||
pageSize,
|
||||
setCurrent,
|
||||
setPageSize,
|
||||
} = useTable<IFilament>({
|
||||
syncWithLocation: false,
|
||||
pagination: {
|
||||
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||
current: initialState.pagination.current,
|
||||
pageSize: initialState.pagination.pageSize,
|
||||
},
|
||||
sorters: {
|
||||
mode: "off", // Disable server-side sorting
|
||||
initial: initialState.sorters,
|
||||
},
|
||||
filters: {
|
||||
mode: "off", // Disable server-side filtering
|
||||
initial: initialState.filters,
|
||||
},
|
||||
});
|
||||
const { tableProps, sorters, setSorters, filters, setFilters, current, pageSize, setCurrent, setPageSize } =
|
||||
useTable<IFilament>({
|
||||
syncWithLocation: false,
|
||||
pagination: {
|
||||
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||
current: initialState.pagination.current,
|
||||
pageSize: initialState.pagination.pageSize,
|
||||
},
|
||||
sorters: {
|
||||
mode: "off", // Disable server-side sorting
|
||||
initial: initialState.sorters,
|
||||
},
|
||||
filters: {
|
||||
mode: "off", // Disable server-side filtering
|
||||
initial: initialState.filters,
|
||||
},
|
||||
});
|
||||
|
||||
// Create state for the columns to show
|
||||
const allColumns: (keyof IFilamentCollapsed & string)[] = [
|
||||
@@ -89,15 +60,10 @@ export const FilamentList: React.FC<IResourceComponentsProps> = () => {
|
||||
"comment",
|
||||
];
|
||||
const defaultColumns = allColumns.filter(
|
||||
(column_id) =>
|
||||
["registered", "density", "diameter", "spool_weight"].indexOf(
|
||||
column_id
|
||||
) === -1
|
||||
(column_id) => ["registered", "density", "diameter", "spool_weight"].indexOf(column_id) === -1
|
||||
);
|
||||
|
||||
const [showColumns, setShowColumns] = React.useState<string[]>(
|
||||
initialState.showColumns ?? defaultColumns
|
||||
);
|
||||
const [showColumns, setShowColumns] = React.useState<string[]>(initialState.showColumns ?? defaultColumns);
|
||||
|
||||
// Type the sorters and filters
|
||||
const typedSorters = typeSorters<IFilamentCollapsed>(sorters);
|
||||
@@ -290,24 +256,9 @@ export const FilamentList: React.FC<IResourceComponentsProps> = () => {
|
||||
title={t("table.actions")}
|
||||
render={(_, record: BaseRecord) => (
|
||||
<Space>
|
||||
<EditButton
|
||||
hideText
|
||||
title={t("buttons.edit")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<ShowButton
|
||||
hideText
|
||||
title={t("buttons.show")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<CloneButton
|
||||
hideText
|
||||
title={t("buttons.clone")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<EditButton hideText title={t("buttons.edit")} size="small" recordItemId={record.id} />
|
||||
<ShowButton hideText title={t("buttons.show")} size="small" recordItemId={record.id} />
|
||||
<CloneButton hideText title={t("buttons.clone")} size="small" recordItemId={record.id} />
|
||||
</Space>
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import React from "react";
|
||||
import {
|
||||
IResourceComponentsProps,
|
||||
useShow,
|
||||
useTranslate,
|
||||
} from "@refinedev/core";
|
||||
import { IResourceComponentsProps, useShow, useTranslate } from "@refinedev/core";
|
||||
import { Show, NumberField, DateField, TextField } from "@refinedev/antd";
|
||||
import { Typography } from "antd";
|
||||
import { NumberFieldUnit } from "../../components/numberField";
|
||||
@@ -79,10 +75,7 @@ export const FilamentShow: React.FC<IResourceComponentsProps> = () => {
|
||||
{!record?.settings_extruder_temp ? (
|
||||
<TextField value="Not Set" />
|
||||
) : (
|
||||
<NumberFieldUnit
|
||||
value={record?.settings_extruder_temp ?? ""}
|
||||
unit="°C"
|
||||
/>
|
||||
<NumberFieldUnit value={record?.settings_extruder_temp ?? ""} unit="°C" />
|
||||
)}
|
||||
<Title level={5}>{t("filament.fields.settings_bed_temp")}</Title>
|
||||
{!record?.settings_bed_temp ? (
|
||||
|
||||
@@ -11,9 +11,7 @@ interface CreateOrCloneProps {
|
||||
mode: "create" | "clone";
|
||||
}
|
||||
|
||||
export const SpoolCreate: React.FC<
|
||||
IResourceComponentsProps & CreateOrCloneProps
|
||||
> = (props) => {
|
||||
export const SpoolCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps> = (props) => {
|
||||
const t = useTranslate();
|
||||
|
||||
const { formProps, saveButtonProps, formLoading } = useForm<ISpool>();
|
||||
@@ -55,11 +53,7 @@ export const SpoolCreate: React.FC<
|
||||
|
||||
return (
|
||||
<Create
|
||||
title={
|
||||
props.mode === "create"
|
||||
? t("spool.titles.create")
|
||||
: t("spool.titles.clone")
|
||||
}
|
||||
title={props.mode === "create" ? t("spool.titles.create") : t("spool.titles.clone")}
|
||||
saveButtonProps={saveButtonProps}
|
||||
isLoading={formLoading}
|
||||
>
|
||||
|
||||
@@ -38,8 +38,7 @@ export const SpoolEdit: React.FC<IResourceComponentsProps> = () => {
|
||||
});
|
||||
|
||||
if (formProps.initialValues) {
|
||||
formProps.initialValues["filament_id"] =
|
||||
formProps.initialValues["filament"].id;
|
||||
formProps.initialValues["filament_id"] = formProps.initialValues["filament"].id;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,41 +1,15 @@
|
||||
import React from "react";
|
||||
import {
|
||||
IResourceComponentsProps,
|
||||
useInvalidate,
|
||||
useTranslate,
|
||||
} from "@refinedev/core";
|
||||
import {
|
||||
useTable,
|
||||
List,
|
||||
EditButton,
|
||||
ShowButton,
|
||||
CloneButton,
|
||||
} from "@refinedev/antd";
|
||||
import { IResourceComponentsProps, useInvalidate, useTranslate } from "@refinedev/core";
|
||||
import { useTable, List, EditButton, ShowButton, CloneButton } from "@refinedev/antd";
|
||||
import { Table, Space, Button, Dropdown, Modal } from "antd";
|
||||
import dayjs from "dayjs";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { genericSorter, typeSorters } from "../../utils/sorting";
|
||||
import { genericFilterer, typeFilters } from "../../utils/filtering";
|
||||
import { ISpool } from "./model";
|
||||
import {
|
||||
TableState,
|
||||
useInitialTableState,
|
||||
useSavedState,
|
||||
useStoreInitialState,
|
||||
} from "../../utils/saveload";
|
||||
import {
|
||||
EditOutlined,
|
||||
FilterOutlined,
|
||||
InboxOutlined,
|
||||
ToTopOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import {
|
||||
DateColumn,
|
||||
FilteredColumn,
|
||||
NumberColumn,
|
||||
SortedColumn,
|
||||
SpoolIconColumn,
|
||||
} from "../../components/column";
|
||||
import { TableState, useInitialTableState, useSavedState, useStoreInitialState } from "../../utils/saveload";
|
||||
import { EditOutlined, FilterOutlined, InboxOutlined, ToTopOutlined } from "@ant-design/icons";
|
||||
import { DateColumn, FilteredColumn, NumberColumn, SortedColumn, SpoolIconColumn } from "../../components/column";
|
||||
import { setSpoolArchived } from "./functions";
|
||||
import SelectAndPrint from "../../components/selectAndPrintDialog";
|
||||
|
||||
@@ -56,43 +30,31 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
|
||||
const initialState = useInitialTableState("spoolList");
|
||||
|
||||
// State for the switch to show archived spools
|
||||
const [showArchived, setShowArchived] = useSavedState(
|
||||
"spoolList-showArchived",
|
||||
false
|
||||
);
|
||||
const [showArchived, setShowArchived] = useSavedState("spoolList-showArchived", false);
|
||||
|
||||
// Fetch data from the API
|
||||
const {
|
||||
tableProps,
|
||||
sorters,
|
||||
setSorters,
|
||||
filters,
|
||||
setFilters,
|
||||
current,
|
||||
pageSize,
|
||||
setCurrent,
|
||||
setPageSize,
|
||||
} = useTable<ISpool>({
|
||||
meta: {
|
||||
queryParams: {
|
||||
["allow_archived"]: showArchived,
|
||||
const { tableProps, sorters, setSorters, filters, setFilters, current, pageSize, setCurrent, setPageSize } =
|
||||
useTable<ISpool>({
|
||||
meta: {
|
||||
queryParams: {
|
||||
["allow_archived"]: showArchived,
|
||||
},
|
||||
},
|
||||
},
|
||||
syncWithLocation: false,
|
||||
pagination: {
|
||||
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||
current: initialState.pagination.current,
|
||||
pageSize: initialState.pagination.pageSize,
|
||||
},
|
||||
sorters: {
|
||||
mode: "off", // Disable server-side sorting
|
||||
initial: initialState.sorters,
|
||||
},
|
||||
filters: {
|
||||
mode: "off", // Disable server-side filtering
|
||||
initial: initialState.filters,
|
||||
},
|
||||
});
|
||||
syncWithLocation: false,
|
||||
pagination: {
|
||||
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||
current: initialState.pagination.current,
|
||||
pageSize: initialState.pagination.pageSize,
|
||||
},
|
||||
sorters: {
|
||||
mode: "off", // Disable server-side sorting
|
||||
initial: initialState.sorters,
|
||||
},
|
||||
filters: {
|
||||
mode: "off", // Disable server-side filtering
|
||||
initial: initialState.filters,
|
||||
},
|
||||
});
|
||||
|
||||
// Create state for the columns to show
|
||||
const allColumns: (keyof ISpoolCollapsed & string)[] = [
|
||||
@@ -111,14 +73,9 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
|
||||
"comment",
|
||||
];
|
||||
const defaultColumns = allColumns.filter(
|
||||
(column_id) =>
|
||||
["registered", "used_length", "remaining_length", "lot_nr"].indexOf(
|
||||
column_id
|
||||
) === -1
|
||||
);
|
||||
const [showColumns, setShowColumns] = React.useState<string[]>(
|
||||
initialState.showColumns ?? defaultColumns
|
||||
(column_id) => ["registered", "used_length", "remaining_length", "lot_nr"].indexOf(column_id) === -1
|
||||
);
|
||||
const [showColumns, setShowColumns] = React.useState<string[]>(initialState.showColumns ?? defaultColumns);
|
||||
|
||||
// Type the sorters and filters
|
||||
const typedSorters = typeSorters<ISpoolCollapsed>(sorters);
|
||||
@@ -141,8 +98,7 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
|
||||
if (element.filament.vendor && "name" in element.filament.vendor) {
|
||||
filament_name = `${element.filament.vendor.name} - ${element.filament.name}`;
|
||||
} else {
|
||||
filament_name =
|
||||
element.filament.name ?? element.filament.id.toString();
|
||||
filament_name = element.filament.name ?? element.filament.id.toString();
|
||||
}
|
||||
return {
|
||||
...element,
|
||||
@@ -200,9 +156,7 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
|
||||
setShowArchived(!showArchived);
|
||||
}}
|
||||
>
|
||||
{showArchived
|
||||
? t("buttons.hideArchived")
|
||||
: t("buttons.showArchived")}
|
||||
{showArchived ? t("buttons.hideArchived") : t("buttons.showArchived")}
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
@@ -361,24 +315,9 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
|
||||
title={t("table.actions")}
|
||||
render={(_, record: ISpoolCollapsed) => (
|
||||
<Space>
|
||||
<EditButton
|
||||
hideText
|
||||
title={t("buttons.edit")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<ShowButton
|
||||
hideText
|
||||
title={t("buttons.show")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<CloneButton
|
||||
hideText
|
||||
title={t("buttons.clone")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<EditButton hideText title={t("buttons.edit")} size="small" recordItemId={record.id} />
|
||||
<ShowButton hideText title={t("buttons.show")} size="small" recordItemId={record.id} />
|
||||
<CloneButton hideText title={t("buttons.clone")} size="small" recordItemId={record.id} />
|
||||
{record.archived ? (
|
||||
<Button
|
||||
icon={<ToTopOutlined />}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import React from "react";
|
||||
import {
|
||||
IResourceComponentsProps,
|
||||
useShow,
|
||||
useTranslate,
|
||||
} from "@refinedev/core";
|
||||
import { IResourceComponentsProps, useShow, useTranslate } from "@refinedev/core";
|
||||
import { Show, NumberField, DateField, TextField } from "@refinedev/antd";
|
||||
import { Typography } from "antd";
|
||||
import { NumberFieldUnit } from "../../components/numberField";
|
||||
|
||||
10
client/src/pages/vendors/create.tsx
vendored
10
client/src/pages/vendors/create.tsx
vendored
@@ -9,20 +9,14 @@ interface CreateOrCloneProps {
|
||||
mode: "create" | "clone";
|
||||
}
|
||||
|
||||
export const VendorCreate: React.FC<
|
||||
IResourceComponentsProps & CreateOrCloneProps
|
||||
> = (props) => {
|
||||
export const VendorCreate: React.FC<IResourceComponentsProps & CreateOrCloneProps> = (props) => {
|
||||
const t = useTranslate();
|
||||
|
||||
const { formProps, saveButtonProps, formLoading } = useForm<IVendor>();
|
||||
|
||||
return (
|
||||
<Create
|
||||
title={
|
||||
props.mode === "create"
|
||||
? t("vendor.titles.create")
|
||||
: t("vendor.titles.clone")
|
||||
}
|
||||
title={props.mode === "create" ? t("vendor.titles.create") : t("vendor.titles.clone")}
|
||||
isLoading={formLoading}
|
||||
saveButtonProps={saveButtonProps}
|
||||
>
|
||||
|
||||
95
client/src/pages/vendors/list.tsx
vendored
95
client/src/pages/vendors/list.tsx
vendored
@@ -1,27 +1,13 @@
|
||||
import React from "react";
|
||||
import {
|
||||
IResourceComponentsProps,
|
||||
BaseRecord,
|
||||
useTranslate,
|
||||
} from "@refinedev/core";
|
||||
import {
|
||||
useTable,
|
||||
List,
|
||||
EditButton,
|
||||
ShowButton,
|
||||
CloneButton,
|
||||
} from "@refinedev/antd";
|
||||
import { IResourceComponentsProps, BaseRecord, useTranslate } from "@refinedev/core";
|
||||
import { useTable, List, EditButton, ShowButton, CloneButton } from "@refinedev/antd";
|
||||
import { Table, Space, Button, Dropdown } from "antd";
|
||||
import dayjs from "dayjs";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { genericSorter, typeSorters } from "../../utils/sorting";
|
||||
import { genericFilterer, typeFilters } from "../../utils/filtering";
|
||||
import { IVendor } from "./model";
|
||||
import {
|
||||
TableState,
|
||||
useInitialTableState,
|
||||
useStoreInitialState,
|
||||
} from "../../utils/saveload";
|
||||
import { TableState, useInitialTableState, useStoreInitialState } from "../../utils/saveload";
|
||||
import { EditOutlined, FilterOutlined } from "@ant-design/icons";
|
||||
import { DateColumn, SortedColumn } from "../../components/column";
|
||||
|
||||
@@ -34,43 +20,27 @@ export const VendorList: React.FC<IResourceComponentsProps> = () => {
|
||||
const initialState = useInitialTableState("vendorList");
|
||||
|
||||
// Fetch data from the API
|
||||
const {
|
||||
tableProps,
|
||||
sorters,
|
||||
setSorters,
|
||||
filters,
|
||||
setFilters,
|
||||
current,
|
||||
pageSize,
|
||||
setCurrent,
|
||||
setPageSize,
|
||||
} = useTable<IVendor>({
|
||||
syncWithLocation: false,
|
||||
pagination: {
|
||||
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||
current: initialState.pagination.current,
|
||||
pageSize: initialState.pagination.pageSize,
|
||||
},
|
||||
sorters: {
|
||||
mode: "off", // Disable server-side sorting
|
||||
initial: initialState.sorters,
|
||||
},
|
||||
filters: {
|
||||
mode: "off", // Disable server-side filtering
|
||||
initial: initialState.filters,
|
||||
},
|
||||
});
|
||||
const { tableProps, sorters, setSorters, filters, setFilters, current, pageSize, setCurrent, setPageSize } =
|
||||
useTable<IVendor>({
|
||||
syncWithLocation: false,
|
||||
pagination: {
|
||||
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||
current: initialState.pagination.current,
|
||||
pageSize: initialState.pagination.pageSize,
|
||||
},
|
||||
sorters: {
|
||||
mode: "off", // Disable server-side sorting
|
||||
initial: initialState.sorters,
|
||||
},
|
||||
filters: {
|
||||
mode: "off", // Disable server-side filtering
|
||||
initial: initialState.filters,
|
||||
},
|
||||
});
|
||||
|
||||
// Create state for the columns to show
|
||||
const allColumns: (keyof IVendor & string)[] = [
|
||||
"id",
|
||||
"name",
|
||||
"registered",
|
||||
"comment",
|
||||
];
|
||||
const [showColumns, setShowColumns] = React.useState<string[]>(
|
||||
initialState.showColumns ?? allColumns
|
||||
);
|
||||
const allColumns: (keyof IVendor & string)[] = ["id", "name", "registered", "comment"];
|
||||
const [showColumns, setShowColumns] = React.useState<string[]>(initialState.showColumns ?? allColumns);
|
||||
|
||||
// Type the sorters and filters
|
||||
const typedSorters = typeSorters<IVendor>(sorters);
|
||||
@@ -181,24 +151,9 @@ export const VendorList: React.FC<IResourceComponentsProps> = () => {
|
||||
title={t("table.actions")}
|
||||
render={(_, record: BaseRecord) => (
|
||||
<Space>
|
||||
<EditButton
|
||||
hideText
|
||||
title={t("buttons.edit")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<ShowButton
|
||||
hideText
|
||||
title={t("buttons.show")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<CloneButton
|
||||
hideText
|
||||
title={t("buttons.clone")}
|
||||
size="small"
|
||||
recordItemId={record.id}
|
||||
/>
|
||||
<EditButton hideText title={t("buttons.edit")} size="small" recordItemId={record.id} />
|
||||
<ShowButton hideText title={t("buttons.show")} size="small" recordItemId={record.id} />
|
||||
<CloneButton hideText title={t("buttons.clone")} size="small" recordItemId={record.id} />
|
||||
</Space>
|
||||
)}
|
||||
/>
|
||||
|
||||
6
client/src/pages/vendors/show.tsx
vendored
6
client/src/pages/vendors/show.tsx
vendored
@@ -1,9 +1,5 @@
|
||||
import React from "react";
|
||||
import {
|
||||
IResourceComponentsProps,
|
||||
useShow,
|
||||
useTranslate,
|
||||
} from "@refinedev/core";
|
||||
import { IResourceComponentsProps, useShow, useTranslate } from "@refinedev/core";
|
||||
import { Show, NumberField, DateField, TextField } from "@refinedev/antd";
|
||||
import { Typography } from "antd";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
Reference in New Issue
Block a user