From 724f0aaf7c09bf61bd073e95f69597449d0104fa Mon Sep 17 00:00:00 2001 From: Vy Duc Tan Date: Tue, 6 Aug 2024 16:23:52 +0700 Subject: [PATCH] refactor: Update package.json scripts, dependencies, and devDependencies for @acme/db (#40) feat: Add updateMutation to EnglishForm component for updating English notions refactor: Update form values in useForm for EnglishForm component refactor: Modify import and assignment in auth/index.ts for better code readability --- hooks/tsconfig.json | 2 +- ui/package.json | 4 ++-- ui/src/alert-modal/AlertModal.tsx | 2 +- ui/src/antd/form/useForm.ts | 32 +++++++++++++++---------------- ui/src/form/useForm.ts | 13 ++++++------- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/hooks/tsconfig.json b/hooks/tsconfig.json index af0217ff..eea5739b 100644 --- a/hooks/tsconfig.json +++ b/hooks/tsconfig.json @@ -5,6 +5,6 @@ "lib": ["dom", "dom.iterable", "ES2022"], "tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json" }, - "include": ["."], + "include": ["*.ts", "src"], "exclude": ["node_modules"] } diff --git a/ui/package.json b/ui/package.json index 5ef1fc50..670dde06 100644 --- a/ui/package.json +++ b/ui/package.json @@ -15,8 +15,8 @@ "default": "./src/*/index.ts" }, "./antd/*": { - "types": "./dist/src/*/index.d.ts", - "default": "./src/*/index.ts" + "types": "./dist/src/antd/*/index.d.ts", + "default": "./src/antd/*/index.ts" }, "./pro/*": { "types": "./dist/src/pro/*/index.d.ts", diff --git a/ui/src/alert-modal/AlertModal.tsx b/ui/src/alert-modal/AlertModal.tsx index 0a682e4a..6deebf6f 100644 --- a/ui/src/alert-modal/AlertModal.tsx +++ b/ui/src/alert-modal/AlertModal.tsx @@ -11,7 +11,7 @@ import { AlertDialogTrigger, } from "./_components"; -type AlertModalProps = Omit & { +export type AlertModalProps = Omit & { onConfirm?: () => void; }; diff --git a/ui/src/antd/form/useForm.ts b/ui/src/antd/form/useForm.ts index 7deafdd6..b746e77f 100644 --- a/ui/src/antd/form/useForm.ts +++ b/ui/src/antd/form/useForm.ts @@ -80,22 +80,22 @@ const useForm = < const resetFields = useCallback((keepStateOptions?: KeepStateOptions) => { if (typeof defaultValues === "function") { - // eslint-disable-next-line @typescript-eslint/no-unsafe-call - defaultValues() - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - .then( - ( - values: - | TFieldValues - | DefaultValues - | ((formValues: TFieldValues) => TFieldValues) - | undefined, - ) => { - return methods.reset(values, keepStateOptions); - }, - ) - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - .catch(() => void 0); + // // eslint-disable-next-line @typescript-eslint/no-unsafe-call + // defaultValues() + // // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + // .then( + // ( + // values: + // | TFieldValues + // | DefaultValues + // | ((formValues: TFieldValues) => TFieldValues) + // | undefined, + // ) => { + // return methods.reset(values, keepStateOptions); + // }, + // ) + // // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + // .catch(() => void 0); } else { methods.reset(defaultValues, keepStateOptions); } diff --git a/ui/src/form/useForm.ts b/ui/src/form/useForm.ts index f898179e..9d25b490 100644 --- a/ui/src/form/useForm.ts +++ b/ui/src/form/useForm.ts @@ -88,12 +88,12 @@ const useForm = < const resetFields = useCallback((keepStateOptions?: KeepStateOptions) => { if (props) { if (typeof props.defaultValues === "function") { - props - .defaultValues() - .then((values: TFieldValues) => { - return methods.reset(values, keepStateOptions); - }) - .catch(() => void 0); + // props + // .defaultValues() + // .then((values: TFieldValues) => { + // return methods.reset(values, keepStateOptions); + // }) + // .catch(() => void 0); } else { methods.reset(props.defaultValues, keepStateOptions); } @@ -119,7 +119,6 @@ const useForm = < useEffect(() => { if ( props?.onValuesChange && - w && !isEqual(formInstance.formState.defaultValues, w) && Object.keys(w).length > 0 ) {