mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
refactor(frontend): optimize useDialogs logic
This commit is contained in:
parent
90a7c55646
commit
f4a438b9dd
@ -32,7 +32,6 @@ export const AttachmentForm: FC<ComponentFormProps<AttachmentFormData>> = ({
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={() => {
|
||||
data?.onChange?.(selected);
|
||||
rest.onSuccess?.();
|
||||
|
||||
@ -98,11 +98,7 @@ export const MenuForm: FC<ComponentFormProps<MenuFormData>> = ({
|
||||
}, [reset, data?.row]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentContainer flexDirection="row">
|
||||
|
||||
@ -71,11 +71,7 @@ export const CategoryForm: FC<ComponentFormProps<ICategory>> = ({
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
@ -93,5 +89,3 @@ export const CategoryForm: FC<ComponentFormProps<ICategory>> = ({
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
CategoryForm.displayName = "CategoryForm";
|
||||
|
||||
@ -106,11 +106,7 @@ export const ContentTypeForm: FC<ComponentFormProps<IContentType>> = ({
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -203,11 +203,7 @@ export const ContentForm: FC<ComponentFormProps<ContentFormData>> = ({
|
||||
}, [content, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
{(contentType?.fields || []).map((contentField, index) => (
|
||||
|
||||
@ -53,7 +53,6 @@ export const ContentImportForm: FC<
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleImportClick}
|
||||
{...WrapperProps}
|
||||
confirmButtonProps={{
|
||||
|
||||
@ -93,11 +93,7 @@ export const ContextVarForm: FC<ComponentFormProps<IContextVar>> = ({
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -81,11 +81,7 @@ export const LabelForm: FC<ComponentFormProps<ILabel>> = ({
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -82,11 +82,7 @@ export const LanguageForm: FC<ComponentFormProps<ILanguage>> = ({
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -89,11 +89,7 @@ export const NlpEntityVarForm: FC<ComponentFormProps<INlpEntity>> = ({
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
{!data ? (
|
||||
|
||||
@ -62,13 +62,8 @@ export const NlpSampleForm: FC<ComponentFormProps<INlpDatasetSample>> = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<Wrapper open={!!WrapperProps?.open} onSubmit={() => {}} {...WrapperProps}>
|
||||
<form>
|
||||
<NlpDatasetSample
|
||||
sample={data || undefined}
|
||||
submitForm={onSubmitForm}
|
||||
/>
|
||||
</form>
|
||||
<Wrapper onSubmit={() => {}} {...WrapperProps}>
|
||||
<NlpDatasetSample sample={data || undefined} submitForm={onSubmitForm} />
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
@ -91,11 +91,7 @@ export const NlpValueForm: FC<
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -117,7 +117,7 @@ export const PermissionsBody: FC<ComponentFormProps<IRole>> = ({
|
||||
}, [models]);
|
||||
|
||||
return (
|
||||
<Wrapper open={!!WrapperProps?.open} onSubmit={() => {}} {...WrapperProps}>
|
||||
<Wrapper onSubmit={() => {}} {...WrapperProps}>
|
||||
<Typography fontWeight={700} sx={{ marginBottom: 2 }}>
|
||||
{role?.name}
|
||||
</Typography>
|
||||
|
||||
@ -70,11 +70,7 @@ export const RoleForm: FC<ComponentFormProps<IRole>> = ({
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -61,11 +61,7 @@ export const SubscriberForm: FC<ComponentFormProps<ISubscriber>> = ({
|
||||
}, [data, reset]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -82,11 +82,7 @@ export const TranslationForm: FC<ComponentFormProps<ITranslation>> = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentItem>
|
||||
<FormLabel>{t("label.original_text")}</FormLabel>
|
||||
|
||||
@ -74,11 +74,7 @@ export const EditUserForm: FC<ComponentFormProps<EditUserFormData>> = ({
|
||||
}, [reset, data?.user]);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -62,11 +62,7 @@ export const InviteUserForm: FC<ComponentFormProps<undefined>> = ({
|
||||
sendInvitation(params);
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
open={!!WrapperProps?.open}
|
||||
onSubmit={handleSubmit(onSubmitForm)}
|
||||
{...WrapperProps}
|
||||
>
|
||||
<Wrapper onSubmit={handleSubmit(onSubmitForm)} {...WrapperProps}>
|
||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||
<ContentContainer>
|
||||
<ContentItem>
|
||||
|
||||
@ -151,8 +151,9 @@ export interface DialogProviderProps {
|
||||
// form dialog
|
||||
export interface FormDialogProps
|
||||
extends FormButtonsProps,
|
||||
Omit<MuiDialogProps, "onSubmit">,
|
||||
Omit<MuiDialogProps, "onSubmit" | "open">,
|
||||
DialogExtraOptions {
|
||||
open?: boolean;
|
||||
title?: string;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user