From 8d03a53228dd596569fe9ac298c84218c9241ed8 Mon Sep 17 00:00:00 2001 From: Donkie Date: Sun, 12 May 2024 16:55:17 +0200 Subject: [PATCH] Formatted client files --- client/.eslintrc.cjs | 6 +--- client/src/pages/spools/create.tsx | 37 +++++++++------------ client/src/pages/spools/edit.tsx | 50 ++++++++++++----------------- client/src/pages/vendors/create.tsx | 4 +-- client/src/pages/vendors/edit.tsx | 4 +-- client/src/pages/vendors/list.tsx | 9 +++++- client/vite.config.ts | 3 +- 7 files changed, 48 insertions(+), 65 deletions(-) diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs index 595490e..73d4b08 100644 --- a/client/.eslintrc.cjs +++ b/client/.eslintrc.cjs @@ -2,11 +2,7 @@ module.exports = { env: { browser: true, es2020: true }, - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:react-hooks/recommended", - ], + extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended"], parser: "@typescript-eslint/parser", parserOptions: { ecmaVersion: "latest", sourceType: "module" }, plugins: ["react-refresh"], diff --git a/client/src/pages/spools/create.tsx b/client/src/pages/spools/create.tsx index c89d9dc..036cad8 100644 --- a/client/src/pages/spools/create.tsx +++ b/client/src/pages/spools/create.tsx @@ -120,16 +120,15 @@ export const SpoolCreate: React.FC { return obj.value === selectedFilamentID; }); - + const filamentChange = (newID: number) => { - const newSelectedFilament = filamentOptions?.find((obj) => { return obj.value === newID; }); const initial_weight = initialWeightValue ?? 0; const spool_weight = spoolWeightValue ?? 0; - + const newFilamentWeight = newSelectedFilament?.weight || 0; const newSpoolWeight = newSelectedFilament?.spool_weight || 0; @@ -168,12 +167,12 @@ export const SpoolCreate: React.FC { - return spoolWeightValue ?? (selectedFilament?.spool_weight ?? 0); - } + return spoolWeightValue ?? selectedFilament?.spool_weight ?? 0; + }; const getFilamentWeight = (): number => { - return initialWeightValue ?? (selectedFilament?.weight ?? 0) - } + return initialWeightValue ?? selectedFilament?.weight ?? 0; + }; const getGrossWeight = (): number => { const net_weight = getFilamentWeight(); @@ -183,31 +182,30 @@ export const SpoolCreate: React.FC { return (selectedFilament?.weight ?? 0) + (selectedFilament?.spool_weight ?? 0); - } + }; const getMeasuredWeight = (): number => { const grossWeight = getGrossWeight(); return grossWeight - usedWeight; - } + }; const getRemainingWeight = (): number => { const initial_weight = getFilamentWeight(); return initial_weight - usedWeight; - } + }; const isMeasuredWeightEnabled = (): boolean => { - if (!isRemainingWeightEnabled()) { return false; } const spool_weight = spoolWeightValue; - return (spool_weight || selectedFilament?.spool_weight) ? true : false; - } - + return spool_weight || selectedFilament?.spool_weight ? true : false; + }; + const isRemainingWeightEnabled = (): boolean => { const initial_weight = initialWeightValue; @@ -216,25 +214,22 @@ export const SpoolCreate: React.FC { - if (weightToEnter >= WeightToEnter.measured_weight) - { + if (weightToEnter >= WeightToEnter.measured_weight) { if (!isMeasuredWeightEnabled()) { setWeightToEnter(WeightToEnter.remaining_weight); return; } } - if (weightToEnter >= WeightToEnter.remaining_weight) - { + if (weightToEnter >= WeightToEnter.remaining_weight) { if (!isRemainingWeightEnabled()) { setWeightToEnter(WeightToEnter.used_weight); return; } } - }, [selectedFilament]) - + }, [selectedFilament]); return ( = () => { const selectedFilament = filamentOptions?.find((obj) => { return obj.value === selectedFilamentID; }); - + const filamentChange = (newID: number) => { - const newSelectedFilament = filamentOptions?.find((obj) => { return obj.value === newID; }); const initial_weight = initialWeightValue ?? 0; const spool_weight = spoolWeightValue ?? 0; - + const newFilamentWeight = newSelectedFilament?.weight || 0; const newSpoolWeight = newSelectedFilament?.spool_weight || 0; @@ -134,13 +133,13 @@ export const SpoolEdit: React.FC = () => { allLocations.push(newLocation.trim()); } -const getSpoolWeight = (): number => { - return spoolWeightValue ?? (selectedFilament?.spool_weight ?? 0); - } + const getSpoolWeight = (): number => { + return spoolWeightValue ?? selectedFilament?.spool_weight ?? 0; + }; const getFilamentWeight = (): number => { - return initialWeightValue ?? (selectedFilament?.weight ?? 0) - } + return initialWeightValue ?? selectedFilament?.weight ?? 0; + }; const getGrossWeight = (): number => { const net_weight = getFilamentWeight(); @@ -150,31 +149,30 @@ const getSpoolWeight = (): number => { const getTotalWeightFromFilament = (): number => { return (selectedFilament?.weight ?? 0) + (selectedFilament?.spool_weight ?? 0); - } + }; const getMeasuredWeight = (): number => { const grossWeight = getGrossWeight(); return grossWeight - usedWeight; - } + }; const getRemainingWeight = (): number => { const initial_weight = getFilamentWeight(); return initial_weight - usedWeight; - } + }; const isMeasuredWeightEnabled = (): boolean => { - if (!isRemainingWeightEnabled()) { return false; } const spool_weight = spoolWeightValue; - return (spool_weight || selectedFilament?.spool_weight) ? true : false; - } - + return spool_weight || selectedFilament?.spool_weight ? true : false; + }; + const isRemainingWeightEnabled = (): boolean => { const initial_weight = initialWeightValue; @@ -183,24 +181,22 @@ const getSpoolWeight = (): number => { } return selectedFilament?.weight ? true : false; - } + }; React.useEffect(() => { - if (weightToEnter >= WeightToEnter.measured_weight) - { + if (weightToEnter >= WeightToEnter.measured_weight) { if (!isMeasuredWeightEnabled()) { setWeightToEnter(WeightToEnter.remaining_weight); return; } } - if (weightToEnter >= WeightToEnter.remaining_weight) - { + if (weightToEnter >= WeightToEnter.remaining_weight) { if (!isRemainingWeightEnabled()) { setWeightToEnter(WeightToEnter.used_weight); return; } } - }, [selectedFilament]) + }, [selectedFilament]); const initialUsedWeight = formProps.initialValues?.used_weight || 0; useEffect(() => { @@ -317,7 +313,7 @@ const getSpoolWeight = (): number => { }, ]} > - + { }} /> - + { }} /> - + - + {t("settings.extra_fields.tab")} {extraFields.data?.map((field, index) => ( diff --git a/client/src/pages/vendors/edit.tsx b/client/src/pages/vendors/edit.tsx index d8fd665..6613f70 100644 --- a/client/src/pages/vendors/edit.tsx +++ b/client/src/pages/vendors/edit.tsx @@ -112,9 +112,7 @@ export const VendorEdit: React.FC = () => { }, ]} > - + {t("settings.extra_fields.tab")} {extraFields.data?.map((field, index) => ( diff --git a/client/src/pages/vendors/list.tsx b/client/src/pages/vendors/list.tsx index dba62ec..9f700fb 100644 --- a/client/src/pages/vendors/list.tsx +++ b/client/src/pages/vendors/list.tsx @@ -7,7 +7,14 @@ import utc from "dayjs/plugin/utc"; import { IVendor } from "./model"; import { TableState, useInitialTableState, useStoreInitialState } from "../../utils/saveload"; import { EditOutlined, EyeOutlined, FilterOutlined, PlusSquareOutlined } from "@ant-design/icons"; -import { DateColumn, RichColumn, SortedColumn, ActionsColumn, CustomFieldColumn, NumberColumn } from "../../components/column"; +import { + DateColumn, + RichColumn, + SortedColumn, + ActionsColumn, + CustomFieldColumn, + NumberColumn, +} from "../../components/column"; import { useLiveify } from "../../components/liveify"; import { removeUndefined } from "../../utils/filtering"; import { EntityType, useGetFields } from "../../utils/queryFields"; diff --git a/client/vite.config.ts b/client/vite.config.ts index 5ba6dc9..c471051 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -2,8 +2,7 @@ import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; import svgr from "vite-plugin-svgr"; - export default defineConfig({ - base: '', + base: "", plugins: [react(), svgr()], });