cleanup forms

This commit is contained in:
Ildar Kamalov
2025-01-21 16:52:12 +03:00
parent 70aeee3037
commit 254b25a026
13 changed files with 143 additions and 143 deletions

View File

@@ -36,7 +36,7 @@ const defaultFormValues: ClientForm = {
};
type Props = {
onSubmit: (...args: unknown[]) => void;
onSubmit: (values: ClientForm) => void;
onClose: () => void;
useGlobalSettings?: boolean;
useGlobalServices?: boolean;
@@ -45,7 +45,7 @@ type Props = {
};
processingAdding: boolean;
processingUpdating: boolean;
tagsOptions: unknown[];
tagsOptions: { label: string; value: string }[];
initialValues?: ClientForm;
};
@@ -79,15 +79,6 @@ export const Form = ({
const safeSearchServices = { ...safe_search };
delete safeSearchServices.enabled;
const onFormSubmit = (values: ClientForm) => {
const data = {
...values,
ids: values.ids.map((idObj) => idObj.name),
};
onSubmit(data);
};
const [activeTabLabel, setActiveTabLabel] = useState('settings');
const tabs = {
@@ -113,7 +104,7 @@ export const Form = ({
return (
<FormProvider {...methods}>
<form onSubmit={handleSubmit(onFormSubmit)}>
<form onSubmit={handleSubmit(onSubmit)}>
<div className="modal-body">
<div className="form__group mb-0">
<div className="form__group">

View File

@@ -21,3 +21,8 @@ export type ClientForm = {
ignore_querylog: boolean;
ignore_statistics: boolean;
};
export type SubmitClientForm = Omit<ClientForm, 'ids' | 'tags'> & {
ids: string[];
tags: string[];
};