From f78dc10c2a591bfbe90c9a1d6f67a443e1ec2737 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Fri, 24 Jan 2025 16:42:30 +0300 Subject: [PATCH] fix forms --- client/src/components/Filters/Check/index.tsx | 2 + client/src/components/Filters/FiltersList.tsx | 7 ++- client/src/components/Filters/Form.tsx | 28 +++++++---- .../src/components/Filters/Rewrites/Form.tsx | 14 ++++-- .../src/components/Filters/Services/Form.tsx | 6 ++- .../Filters/Services/ServiceField.tsx | 3 +- .../Form/components/BlockedServices.tsx | 4 ++ .../Clients/Form/components/ClientIds.tsx | 3 ++ .../Clients/Form/components/MainSettings.tsx | 19 ++++++-- .../Clients/Form/components/UpstreamDns.tsx | 31 ++++++------ .../Settings/Clients/Form/index.tsx | 6 +-- .../components/Settings/Encryption/Form.tsx | 13 +++++ .../components/Settings/StatsConfig/Form.tsx | 8 +--- .../components/ui/Controls/Checkbox/index.tsx | 3 +- .../src/components/ui/Controls/Textarea.tsx | 47 ++++++++++++------- .../components/ui/Guide/MobileConfigForm.tsx | 23 +++++---- 16 files changed, 144 insertions(+), 73 deletions(-) diff --git a/client/src/components/Filters/Check/index.tsx b/client/src/components/Filters/Check/index.tsx index 32024397..996d6b75 100644 --- a/client/src/components/Filters/Check/index.tsx +++ b/client/src/components/Filters/Check/index.tsx @@ -48,6 +48,7 @@ const Check = ({ onSubmit }: Props) => { { diff --git a/client/src/components/Filters/FiltersList.tsx b/client/src/components/Filters/FiltersList.tsx index fb9bedb7..ca0d1fbb 100644 --- a/client/src/components/Filters/FiltersList.tsx +++ b/client/src/components/Filters/FiltersList.tsx @@ -74,7 +74,12 @@ export const FiltersList = ({ categories, filters, selectedSources }: Props) => name={id} control={control} render={({ field }) => ( - + )} /> {renderIcons(iconsData)} diff --git a/client/src/components/Filters/Form.tsx b/client/src/components/Filters/Form.tsx index 82a61df9..9641cfd4 100644 --- a/client/src/components/Filters/Form.tsx +++ b/client/src/components/Filters/Form.tsx @@ -15,13 +15,13 @@ type FormValues = { }; type Props = { - closeModal: (...args: unknown[]) => void; + closeModal: () => void; onSubmit: (values: FormValues) => void; processingAddFilter: boolean; processingConfigFilter: boolean; whitelist?: boolean; modalType: string; - toggleFilteringModal: (...args: unknown[]) => void; + toggleFilteringModal: ({ type }: { type?: keyof typeof MODAL_TYPE }) => void; selectedSources?: Record; initialValues?: FormValues; }; @@ -42,14 +42,14 @@ export const Form = ({ const methods = useForm({ defaultValues: initialValues }); const { handleSubmit, control } = methods; - const openModal = (modalType: any, timeout = MODAL_OPEN_TIMEOUT) => { - toggleFilteringModal(); + const openModal = (modalType: keyof typeof MODAL_TYPE, timeout = MODAL_OPEN_TIMEOUT) => { + toggleFilteringModal(undefined); setTimeout(() => toggleFilteringModal({ type: modalType }), timeout); }; - const openFilteringListModal = () => openModal(MODAL_TYPE.CHOOSE_FILTERING_LIST); + const openFilteringListModal = () => openModal('CHOOSE_FILTERING_LIST'); - const openAddFiltersModal = () => openModal(MODAL_TYPE.ADD_FILTERS); + const openAddFiltersModal = () => openModal('ADD_FILTERS'); return ( @@ -81,8 +81,15 @@ export const Form = ({ ( - + render={({ field, fieldState }) => ( + )} /> @@ -92,11 +99,13 @@ export const Form = ({ name="url" control={control} rules={{ validate: { validateRequiredValue, validatePath } }} - render={({ field }) => ( + render={({ field, fieldState }) => ( )} @@ -118,6 +127,7 @@ export const Form = ({ {modalType !== MODAL_TYPE.SELECT_MODAL_TYPE && (