fix client form

This commit is contained in:
Ildar Kamalov
2025-01-21 14:27:05 +03:00
parent 28cd8a41d2
commit 290987d020
5 changed files with 26 additions and 115 deletions

View File

@@ -29,7 +29,6 @@ export const BlockedServices = ({ services }: Props) => {
<ServiceField
{...field}
placeholder={t('blocked_services_global')}
disabled={useGlobalServices}
className="service--global"
/>
)}

View File

@@ -5,7 +5,7 @@ import { Controller, FormProvider, useForm } from 'react-hook-form';
import Select from 'react-select';
import Tabs from '../../../ui/Tabs';
import { CLIENT_ID_LINK } from '../../../../helpers/constants';
import { CLIENT_ID_LINK, LOCAL_TIMEZONE_VALUE } from '../../../../helpers/constants';
import { RootState } from '../../../../initialState';
import { Input } from '../../../ui/Controls/Input';
import { validateRequiredValue } from '../../../../helpers/validators';
@@ -14,6 +14,27 @@ import { BlockedServices, ClientIds, MainSettings, ScheduleServices, UpstreamDns
import '../Service.css';
const defaultFormValues: ClientForm = {
ids: [{ name: '' }],
name: '',
tags: [],
use_global_settings: false,
filtering_enabled: false,
safebrowsing_enabled: false,
parental_enabled: false,
ignore_querylog: false,
ignore_statistics: false,
blocked_services: {},
safe_search: { enabled: false },
upstreams: '',
upstreams_cache_enabled: false,
upstreams_cache_size: 0,
use_global_blocked_services: false,
blocked_services_schedule: {
time_zone: LOCAL_TIMEZONE_VALUE,
},
};
type Props = {
onSubmit: (...args: unknown[]) => void;
onClose: () => void;
@@ -38,7 +59,10 @@ export const Form = ({
}: Props) => {
const { t } = useTranslation();
const methods = useForm<ClientForm>({
defaultValues: initialValues,
defaultValues: {
...defaultFormValues,
...initialValues,
},
mode: 'onChange',
});

View File

@@ -1,9 +1,7 @@
import {
ALL_INTERFACES_IP,
BLOCKING_MODES,
DAY,
DEFAULT_LOGS_FILTER,
INSTALL_FIRST_STEP,
STANDARD_DNS_PORT,
STANDARD_WEB_PORT,
TIME_UNITS,