diff --git a/client/src/App.tsx b/client/src/App.tsx
index 244c364..eacf658 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -1,13 +1,7 @@
import { Refine } from "@refinedev/core";
import { RefineKbar, RefineKbarProvider } from "@refinedev/kbar";
-import {
- ErrorComponent,
- notificationProvider,
- ThemedLayoutV2,
- ThemedSiderV2,
- ThemedTitleV2,
-} from "@refinedev/antd";
+import { ErrorComponent, notificationProvider, ThemedLayoutV2, ThemedSiderV2, ThemedTitleV2 } from "@refinedev/antd";
import "@refinedev/antd/dist/reset.css";
import routerBindings, {
@@ -21,11 +15,7 @@ import { BrowserRouter, Outlet, Route, Routes } from "react-router-dom";
import { Header } from "./components/header";
import { ColorModeContextProvider } from "./contexts/color-mode";
import { ReactComponent as Logo } from "./icon.svg";
-import {
- FileOutlined,
- HighlightOutlined,
- UserOutlined,
-} from "@ant-design/icons";
+import { FileOutlined, HighlightOutlined, UserOutlined } from "@ant-design/icons";
import { ConfigProvider } from "antd";
import { Footer } from "antd/es/layout/layout";
import { Version } from "./components/version";
@@ -40,14 +30,10 @@ interface PageProps {
mode?: "create" | "clone";
}
-const LoadablePage = loadable(
- (props: PageProps) => import(`./pages/${props.resource}/${props.page}.tsx`),
- {
- fallback:
Page is Loading...
,
- cacheKey: (props: PageProps) =>
- `${props.resource}-${props.page}-${props.mode ?? ""}`,
- }
-);
+const LoadablePage = loadable((props: PageProps) => import(`./pages/${props.resource}/${props.page}.tsx`), {
+ fallback: Page is Loading...
,
+ cacheKey: (props: PageProps) => `${props.resource}-${props.page}-${props.mode ?? ""}`,
+});
function App() {
const { t, i18n } = useTranslation();
@@ -63,9 +49,7 @@ function App() {
React.useEffect(() => {
const fetchLocale = async () => {
const locale = await import(
- `./../node_modules/antd/es/locale/${languages[
- i18n.language
- ].fullCode.replace("-", "_")}.js`
+ `./../node_modules/antd/es/locale/${languages[i18n.language].fullCode.replace("-", "_")}.js`
);
setAntdLocale(locale.default);
};
@@ -77,8 +61,8 @@ function App() {
<>
Missing API URL
- App was built without an API URL. Please set the VITE_APIURL
- environment variable to the URL of your Spoolman API.
+ App was built without an API URL. Please set the VITE_APIURL environment variable to the URL of your Spoolman
+ API.
>
);
@@ -154,11 +138,7 @@ function App() {
(
- }
- />
+ } />
)}
/>
)}
@@ -172,117 +152,30 @@ function App() {
}
>
- }
- />
+ } />
- }
- />
-
- }
- />
-
- }
- />
- }
- />
- }
- />
+ } />
+ } />
+ } />
+ } />
+ } />
-
- }
- />
-
- }
- />
+ } />
+ } />
- }
- />
-
- }
- />
-
- }
+ element={ }
/>
+ } />
+ } />
- }
- />
-
- }
- />
-
- }
- />
- }
- />
- }
- />
+ } />
+ } />
+ } />
+ } />
+ } />
} />
diff --git a/client/src/components/column.tsx b/client/src/components/column.tsx
index 7677aec..af7e124 100644
--- a/client/src/components/column.tsx
+++ b/client/src/components/column.tsx
@@ -1,11 +1,7 @@
import { Col, Row, Table } from "antd";
import { ColumnProps as AntdColumnProps } from "antd/es/table";
import { ColumnFilterItem } from "antd/es/table/interface";
-import {
- getFiltersForField,
- typeFilters,
- useListFiltersForField,
-} from "../utils/filtering";
+import { getFiltersForField, typeFilters, useListFiltersForField } from "../utils/filtering";
import { TableState } from "../utils/saveload";
import { getSortOrderForField, typeSorters } from "../utils/sorting";
import { NumberFieldUnit } from "./numberField";
@@ -40,14 +36,9 @@ interface CustomColumnProps {
) => React.HTMLAttributes | React.TdHTMLAttributes;
}
-function Column(
- props: BaseColumnProps & FilteredColumnProps & CustomColumnProps
-) {
+function Column(props: BaseColumnProps & FilteredColumnProps & CustomColumnProps) {
const t = useTranslate();
- if (
- props.tableState.showColumns &&
- !props.tableState.showColumns.includes(props.id)
- ) {
+ if (props.tableState.showColumns && !props.tableState.showColumns.includes(props.id)) {
return <>>;
}
const typedSorters = typeSorters(props.tableState.sorters);
diff --git a/client/src/components/header/index.tsx b/client/src/components/header/index.tsx
index eacdd25..5c3ddcb 100644
--- a/client/src/components/header/index.tsx
+++ b/client/src/components/header/index.tsx
@@ -1,15 +1,7 @@
import { DownOutlined } from "@ant-design/icons";
import type { RefineThemedLayoutV2HeaderProps } from "@refinedev/antd";
import { useGetLocale, useSetLocale } from "@refinedev/core";
-import {
- Button,
- Dropdown,
- Layout as AntdLayout,
- MenuProps,
- Space,
- Switch,
- theme,
-} from "antd";
+import { Button, Dropdown, Layout as AntdLayout, MenuProps, Space, Switch, theme } from "antd";
import React, { useContext } from "react";
import { ColorModeContext } from "../../contexts/color-mode";
@@ -19,9 +11,7 @@ import QRCodeScannerModal from "../qrCodeScanner";
const { useToken } = theme;
-export const Header: React.FC = ({
- sticky,
-}) => {
+export const Header: React.FC = ({ sticky }) => {
const { token } = useToken();
const locale = useGetLocale();
const changeLanguage = useSetLocale();
@@ -29,19 +19,12 @@ export const Header: React.FC = ({
const currentLocale = locale();
- const menuItems: MenuProps["items"] = [...(Object.keys(languages) || [])]
- .sort()
- .map((lang: string) => ({
- key: lang,
- onClick: () => changeLanguage(lang),
- icon: (
-
- ),
- label: languages[lang].name,
- }));
+ const menuItems: MenuProps["items"] = [...(Object.keys(languages) || [])].sort().map((lang: string) => ({
+ key: lang,
+ onClick: () => changeLanguage(lang),
+ icon: ,
+ label: languages[lang].name,
+ }));
const headerStyles: React.CSSProperties = {
backgroundColor: token.colorBgElevated,
@@ -69,11 +52,7 @@ export const Header: React.FC = ({
>
-
+
{languages[currentLocale ?? "en"].name}
diff --git a/client/src/components/numberField.tsx b/client/src/components/numberField.tsx
index c5788a4..b8bf0da 100644
--- a/client/src/components/numberField.tsx
+++ b/client/src/components/numberField.tsx
@@ -5,11 +5,7 @@ import { NumberFieldProps } from "@refinedev/antd/dist/components/fields/types";
const { Text } = Typography;
function toLocaleStringSupportsOptions() {
- return !!(
- typeof Intl == "object" &&
- Intl &&
- typeof Intl.NumberFormat == "function"
- );
+ return !!(typeof Intl == "object" && Intl && typeof Intl.NumberFormat == "function");
}
type Props = NumberFieldProps & {
@@ -21,20 +17,12 @@ type Props = NumberFieldProps & {
*
* @see {@link https://refine.dev/docs/ui-frameworks/antd/components/fields/number} for more details.
*/
-export const NumberFieldUnit: React.FC = ({
- value,
- locale,
- options,
- ...rest
-}) => {
+export const NumberFieldUnit: React.FC = ({ value, locale, options, ...rest }) => {
const number = Number(value);
return (
- {toLocaleStringSupportsOptions()
- ? number.toLocaleString(locale, options)
- : number}{" "}
- {rest.unit}
+ {toLocaleStringSupportsOptions() ? number.toLocaleString(locale, options) : number} {rest.unit}
);
};
diff --git a/client/src/components/qrCodeScanner.tsx b/client/src/components/qrCodeScanner.tsx
index cd09006..bb66dc6 100644
--- a/client/src/components/qrCodeScanner.tsx
+++ b/client/src/components/qrCodeScanner.tsx
@@ -22,18 +22,8 @@ const QRCodeScannerModal: React.FC = () => {
return (
<>
- setVisible(true)}
- icon={ }
- shape="circle"
- />
- setVisible(false)}
- footer={null}
- title={t("scanner.title")}
- >
+ setVisible(true)} icon={ } shape="circle" />
+ setVisible(false)} footer={null} title={t("scanner.title")}>
{t("scanner.description")}
{
setLastError(t("scanner.error.notAllowed"));
} else if (
error.name === "InsecureContextError" ||
- (location.protocol !== "https:" &&
- navigator.mediaDevices === undefined)
+ (location.protocol !== "https:" && navigator.mediaDevices === undefined)
) {
setLastError(t("scanner.error.insecureContext"));
} else if (error.name === "StreamApiNotSupportedError") {
diff --git a/client/src/components/spoolSelectModal.tsx b/client/src/components/spoolSelectModal.tsx
index 71faed9..1f935c5 100644
--- a/client/src/components/spoolSelectModal.tsx
+++ b/client/src/components/spoolSelectModal.tsx
@@ -20,12 +20,7 @@ interface ISpoolCollapsed extends ISpool {
material?: string;
}
-const SpoolSelectModal: React.FC = ({
- visible,
- description,
- onCancel,
- onContinue,
-}) => {
+const SpoolSelectModal: React.FC = ({ visible, description, onCancel, onContinue }) => {
const [selectedItems, setSelectedItems] = useState([]);
const [showArchived, setShowArchived] = useState(false);
const [messageApi, contextHolder] = message.useMessage();
@@ -65,8 +60,7 @@ const SpoolSelectModal: React.FC = ({
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,
@@ -91,9 +85,7 @@ const SpoolSelectModal: React.FC = ({
// Function to add/remove all filtered items from selected items
const selectUnselectFiltered = (select: boolean) => {
setSelectedItems((prevSelected) => {
- const filtered = filteredDataSource
- .map((spool) => spool.id)
- .filter((spool) => !prevSelected.includes(spool));
+ const filtered = filteredDataSource.map((spool) => spool.id).filter((spool) => !prevSelected.includes(spool));
return select ? [...prevSelected, ...filtered] : filtered;
});
};
@@ -101,16 +93,12 @@ const SpoolSelectModal: React.FC = ({
// Handler for selecting/unselecting individual items
const handleSelectItem = (item: number) => {
setSelectedItems((prevSelected) =>
- prevSelected.includes(item)
- ? prevSelected.filter((selected) => selected !== item)
- : [...prevSelected, item]
+ prevSelected.includes(item) ? prevSelected.filter((selected) => selected !== item) : [...prevSelected, item]
);
};
// State for the select/unselect all checkbox
- const isAllFilteredSelected = filteredDataSource.every((spool) =>
- selectedItems.includes(spool.id)
- );
+ const isAllFilteredSelected = filteredDataSource.every((spool) => selectedItems.includes(spool.id));
return (
= ({
});
return;
}
- onContinue(
- dataSource.filter((spool) => selectedItems.includes(spool.id))
- );
+ onContinue(dataSource.filter((spool) => selectedItems.includes(spool.id)));
}}
width={600}
>
@@ -144,10 +130,7 @@ const SpoolSelectModal: React.FC = ({
(
- handleSelectItem(item.id)}
- />
+ handleSelectItem(item.id)} />
)}
/>
{SortedColumn({
@@ -197,9 +180,7 @@ const SpoolSelectModal: React.FC = ({
// Remove archived spools from selected items
setSelectedItems((prevSelected) =>
prevSelected.filter(
- (selected) =>
- dataSource.find((spool) => spool.id === selected)
- ?.archived !== true
+ (selected) => dataSource.find((spool) => spool.id === selected)?.archived !== true
)
);
}
diff --git a/client/src/contexts/color-mode/index.tsx b/client/src/contexts/color-mode/index.tsx
index b0c7d5a..3dc3862 100644
--- a/client/src/contexts/color-mode/index.tsx
+++ b/client/src/contexts/color-mode/index.tsx
@@ -7,22 +7,14 @@ type ColorModeContextType = {
setMode: (mode: string) => void;
};
-export const ColorModeContext = createContext(
- {} as ColorModeContextType
-);
+export const ColorModeContext = createContext({} as ColorModeContextType);
-export const ColorModeContextProvider: React.FC = ({
- children,
-}) => {
+export const ColorModeContextProvider: React.FC = ({ children }) => {
const colorModeFromLocalStorage = localStorage.getItem("colorMode");
- const isSystemPreferenceDark = window?.matchMedia(
- "(prefers-color-scheme: dark)"
- ).matches;
+ const isSystemPreferenceDark = window?.matchMedia("(prefers-color-scheme: dark)").matches;
const systemPreference = isSystemPreferenceDark ? "dark" : "light";
- const [mode, setMode] = useState(
- colorModeFromLocalStorage || systemPreference
- );
+ const [mode, setMode] = useState(colorModeFromLocalStorage || systemPreference);
useEffect(() => {
window.localStorage.setItem("colorMode", mode);
diff --git a/client/src/pages/filaments/create.tsx b/client/src/pages/filaments/create.tsx
index bcbc89e..274d95d 100644
--- a/client/src/pages/filaments/create.tsx
+++ b/client/src/pages/filaments/create.tsx
@@ -11,9 +11,7 @@ interface CreateOrCloneProps {
mode: "create" | "clone";
}
-export const FilamentCreate: React.FC<
- IResourceComponentsProps & CreateOrCloneProps
-> = (props) => {
+export const FilamentCreate: React.FC = (props) => {
const t = useTranslate();
const { formProps, saveButtonProps, formLoading } = useForm();
@@ -96,12 +94,7 @@ export const FilamentCreate: React.FC<
},
]}
>
-
+
-
+
-
+
= () => {
});
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 = () => {
},
]}
>
-
+
= () => {
},
]}
>
-
+
= () => {
},
]}
>
-
+
= () => {
const initialState = useInitialTableState("filamentList");
// Fetch data from the API
- const {
- tableProps,
- sorters,
- setSorters,
- filters,
- setFilters,
- current,
- pageSize,
- setCurrent,
- setPageSize,
- } = useTable({
- 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({
+ 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 = () => {
"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(
- initialState.showColumns ?? defaultColumns
- );
+ const [showColumns, setShowColumns] = React.useState(initialState.showColumns ?? defaultColumns);
// Type the sorters and filters
const typedSorters = typeSorters(sorters);
@@ -290,24 +256,9 @@ export const FilamentList: React.FC = () => {
title={t("table.actions")}
render={(_, record: BaseRecord) => (
-
-
-
+
+
+
)}
/>
diff --git a/client/src/pages/filaments/show.tsx b/client/src/pages/filaments/show.tsx
index cf9a193..6c37c0f 100644
--- a/client/src/pages/filaments/show.tsx
+++ b/client/src/pages/filaments/show.tsx
@@ -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 = () => {
{!record?.settings_extruder_temp ? (
) : (
-
+
)}
{t("filament.fields.settings_bed_temp")}
{!record?.settings_bed_temp ? (
diff --git a/client/src/pages/spools/create.tsx b/client/src/pages/spools/create.tsx
index 43a1f49..ba13d2c 100644
--- a/client/src/pages/spools/create.tsx
+++ b/client/src/pages/spools/create.tsx
@@ -11,9 +11,7 @@ interface CreateOrCloneProps {
mode: "create" | "clone";
}
-export const SpoolCreate: React.FC<
- IResourceComponentsProps & CreateOrCloneProps
-> = (props) => {
+export const SpoolCreate: React.FC = (props) => {
const t = useTranslate();
const { formProps, saveButtonProps, formLoading } = useForm();
@@ -55,11 +53,7 @@ export const SpoolCreate: React.FC<
return (
diff --git a/client/src/pages/spools/edit.tsx b/client/src/pages/spools/edit.tsx
index 168b3ad..4107433 100644
--- a/client/src/pages/spools/edit.tsx
+++ b/client/src/pages/spools/edit.tsx
@@ -38,8 +38,7 @@ export const SpoolEdit: React.FC = () => {
});
if (formProps.initialValues) {
- formProps.initialValues["filament_id"] =
- formProps.initialValues["filament"].id;
+ formProps.initialValues["filament_id"] = formProps.initialValues["filament"].id;
}
return (
diff --git a/client/src/pages/spools/list.tsx b/client/src/pages/spools/list.tsx
index 9cddaa7..7bcaa2c 100644
--- a/client/src/pages/spools/list.tsx
+++ b/client/src/pages/spools/list.tsx
@@ -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 = () => {
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({
- meta: {
- queryParams: {
- ["allow_archived"]: showArchived,
+ const { tableProps, sorters, setSorters, filters, setFilters, current, pageSize, setCurrent, setPageSize } =
+ useTable({
+ 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 = () => {
"comment",
];
const defaultColumns = allColumns.filter(
- (column_id) =>
- ["registered", "used_length", "remaining_length", "lot_nr"].indexOf(
- column_id
- ) === -1
- );
- const [showColumns, setShowColumns] = React.useState(
- initialState.showColumns ?? defaultColumns
+ (column_id) => ["registered", "used_length", "remaining_length", "lot_nr"].indexOf(column_id) === -1
);
+ const [showColumns, setShowColumns] = React.useState(initialState.showColumns ?? defaultColumns);
// Type the sorters and filters
const typedSorters = typeSorters(sorters);
@@ -141,8 +98,7 @@ export const SpoolList: React.FC = () => {
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 = () => {
setShowArchived(!showArchived);
}}
>
- {showArchived
- ? t("buttons.hideArchived")
- : t("buttons.showArchived")}
+ {showArchived ? t("buttons.hideArchived") : t("buttons.showArchived")}
= () => {
title={t("table.actions")}
render={(_, record: ISpoolCollapsed) => (
-
-
-
+
+
+
{record.archived ? (
}
diff --git a/client/src/pages/spools/show.tsx b/client/src/pages/spools/show.tsx
index 38ac0e0..1542915 100644
--- a/client/src/pages/spools/show.tsx
+++ b/client/src/pages/spools/show.tsx
@@ -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";
diff --git a/client/src/pages/vendors/create.tsx b/client/src/pages/vendors/create.tsx
index 252da91..3a5de6a 100644
--- a/client/src/pages/vendors/create.tsx
+++ b/client/src/pages/vendors/create.tsx
@@ -9,20 +9,14 @@ interface CreateOrCloneProps {
mode: "create" | "clone";
}
-export const VendorCreate: React.FC<
- IResourceComponentsProps & CreateOrCloneProps
-> = (props) => {
+export const VendorCreate: React.FC = (props) => {
const t = useTranslate();
const { formProps, saveButtonProps, formLoading } = useForm();
return (
diff --git a/client/src/pages/vendors/list.tsx b/client/src/pages/vendors/list.tsx
index b254757..aa812f9 100644
--- a/client/src/pages/vendors/list.tsx
+++ b/client/src/pages/vendors/list.tsx
@@ -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 = () => {
const initialState = useInitialTableState("vendorList");
// Fetch data from the API
- const {
- tableProps,
- sorters,
- setSorters,
- filters,
- setFilters,
- current,
- pageSize,
- setCurrent,
- setPageSize,
- } = useTable({
- 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({
+ 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(
- initialState.showColumns ?? allColumns
- );
+ const allColumns: (keyof IVendor & string)[] = ["id", "name", "registered", "comment"];
+ const [showColumns, setShowColumns] = React.useState(initialState.showColumns ?? allColumns);
// Type the sorters and filters
const typedSorters = typeSorters(sorters);
@@ -181,24 +151,9 @@ export const VendorList: React.FC = () => {
title={t("table.actions")}
render={(_, record: BaseRecord) => (
-
-
-
+
+
+
)}
/>
diff --git a/client/src/pages/vendors/show.tsx b/client/src/pages/vendors/show.tsx
index d1373de..0bea96c 100644
--- a/client/src/pages/vendors/show.tsx
+++ b/client/src/pages/vendors/show.tsx
@@ -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";