From f4a438b9dd5e26ff9eadc249aa624c2961538b53 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Sun, 9 Feb 2025 01:45:35 +0100 Subject: [PATCH] refactor(frontend): optimize useDialogs logic --- .../src/app-components/attachment/AttachmentForm.tsx | 1 - frontend/src/components/Menu/MenuForm.tsx | 6 +----- frontend/src/components/categories/CategoryForm.tsx | 8 +------- .../src/components/content-types/ContentTypeForm.tsx | 6 +----- frontend/src/components/contents/ContentForm.tsx | 6 +----- frontend/src/components/contents/ContentImportForm.tsx | 1 - frontend/src/components/context-vars/ContextVarForm.tsx | 6 +----- frontend/src/components/labels/LabelForm.tsx | 6 +----- frontend/src/components/languages/LanguageForm.tsx | 6 +----- frontend/src/components/nlp/components/NlpEntityForm.tsx | 6 +----- frontend/src/components/nlp/components/NlpSampleForm.tsx | 9 ++------- frontend/src/components/nlp/components/NlpValueForm.tsx | 6 +----- frontend/src/components/roles/PermissionsBody.tsx | 2 +- frontend/src/components/roles/RoleForm.tsx | 6 +----- frontend/src/components/subscribers/SubscriberForm.tsx | 6 +----- frontend/src/components/translations/TranslationForm.tsx | 6 +----- frontend/src/components/users/EditUserForm.tsx | 6 +----- frontend/src/components/users/InviteUserForm.tsx | 6 +----- frontend/src/types/common/dialogs.types.ts | 3 ++- 19 files changed, 19 insertions(+), 83 deletions(-) diff --git a/frontend/src/app-components/attachment/AttachmentForm.tsx b/frontend/src/app-components/attachment/AttachmentForm.tsx index d7d8aa4a..621273a2 100644 --- a/frontend/src/app-components/attachment/AttachmentForm.tsx +++ b/frontend/src/app-components/attachment/AttachmentForm.tsx @@ -32,7 +32,6 @@ export const AttachmentForm: FC> = ({ return ( { data?.onChange?.(selected); rest.onSuccess?.(); diff --git a/frontend/src/components/Menu/MenuForm.tsx b/frontend/src/components/Menu/MenuForm.tsx index cc8ae113..39945c35 100644 --- a/frontend/src/components/Menu/MenuForm.tsx +++ b/frontend/src/components/Menu/MenuForm.tsx @@ -98,11 +98,7 @@ export const MenuForm: FC> = ({ }, [reset, data?.row]); return ( - +
diff --git a/frontend/src/components/categories/CategoryForm.tsx b/frontend/src/components/categories/CategoryForm.tsx index abeb522c..a4153ae4 100644 --- a/frontend/src/components/categories/CategoryForm.tsx +++ b/frontend/src/components/categories/CategoryForm.tsx @@ -71,11 +71,7 @@ export const CategoryForm: FC> = ({ }, [data, reset]); return ( - + @@ -93,5 +89,3 @@ export const CategoryForm: FC> = ({ ); }; - -CategoryForm.displayName = "CategoryForm"; diff --git a/frontend/src/components/content-types/ContentTypeForm.tsx b/frontend/src/components/content-types/ContentTypeForm.tsx index de23f7db..36d595d2 100644 --- a/frontend/src/components/content-types/ContentTypeForm.tsx +++ b/frontend/src/components/content-types/ContentTypeForm.tsx @@ -106,11 +106,7 @@ export const ContentTypeForm: FC> = ({ }, [data, reset]); return ( - + diff --git a/frontend/src/components/contents/ContentForm.tsx b/frontend/src/components/contents/ContentForm.tsx index 3315b4c2..f3600a21 100644 --- a/frontend/src/components/contents/ContentForm.tsx +++ b/frontend/src/components/contents/ContentForm.tsx @@ -203,11 +203,7 @@ export const ContentForm: FC> = ({ }, [content, reset]); return ( - + {(contentType?.fields || []).map((contentField, index) => ( diff --git a/frontend/src/components/contents/ContentImportForm.tsx b/frontend/src/components/contents/ContentImportForm.tsx index 52fe9dbb..0cda29ad 100644 --- a/frontend/src/components/contents/ContentImportForm.tsx +++ b/frontend/src/components/contents/ContentImportForm.tsx @@ -53,7 +53,6 @@ export const ContentImportForm: FC< return ( > = ({ }, [data, reset]); return ( - + diff --git a/frontend/src/components/labels/LabelForm.tsx b/frontend/src/components/labels/LabelForm.tsx index f4f713c0..e716b83b 100644 --- a/frontend/src/components/labels/LabelForm.tsx +++ b/frontend/src/components/labels/LabelForm.tsx @@ -81,11 +81,7 @@ export const LabelForm: FC> = ({ }, [data, reset]); return ( - + diff --git a/frontend/src/components/languages/LanguageForm.tsx b/frontend/src/components/languages/LanguageForm.tsx index 3f42f074..e8c9aabc 100644 --- a/frontend/src/components/languages/LanguageForm.tsx +++ b/frontend/src/components/languages/LanguageForm.tsx @@ -82,11 +82,7 @@ export const LanguageForm: FC> = ({ }, [data, reset]); return ( - + diff --git a/frontend/src/components/nlp/components/NlpEntityForm.tsx b/frontend/src/components/nlp/components/NlpEntityForm.tsx index ada67efd..8c503223 100644 --- a/frontend/src/components/nlp/components/NlpEntityForm.tsx +++ b/frontend/src/components/nlp/components/NlpEntityForm.tsx @@ -89,11 +89,7 @@ export const NlpEntityVarForm: FC> = ({ }, [data, reset]); return ( - + {!data ? ( diff --git a/frontend/src/components/nlp/components/NlpSampleForm.tsx b/frontend/src/components/nlp/components/NlpSampleForm.tsx index 59582425..b60fc174 100644 --- a/frontend/src/components/nlp/components/NlpSampleForm.tsx +++ b/frontend/src/components/nlp/components/NlpSampleForm.tsx @@ -62,13 +62,8 @@ export const NlpSampleForm: FC> = ({ }; return ( - {}} {...WrapperProps}> - - - + {}} {...WrapperProps}> + ); }; diff --git a/frontend/src/components/nlp/components/NlpValueForm.tsx b/frontend/src/components/nlp/components/NlpValueForm.tsx index 68bcbe98..6f4209d3 100644 --- a/frontend/src/components/nlp/components/NlpValueForm.tsx +++ b/frontend/src/components/nlp/components/NlpValueForm.tsx @@ -91,11 +91,7 @@ export const NlpValueForm: FC< }, [data, reset]); return ( - +
diff --git a/frontend/src/components/roles/PermissionsBody.tsx b/frontend/src/components/roles/PermissionsBody.tsx index 39f3cf89..f2802e33 100644 --- a/frontend/src/components/roles/PermissionsBody.tsx +++ b/frontend/src/components/roles/PermissionsBody.tsx @@ -117,7 +117,7 @@ export const PermissionsBody: FC> = ({ }, [models]); return ( - {}} {...WrapperProps}> + {}} {...WrapperProps}> {role?.name} diff --git a/frontend/src/components/roles/RoleForm.tsx b/frontend/src/components/roles/RoleForm.tsx index 5cc39de2..76033736 100644 --- a/frontend/src/components/roles/RoleForm.tsx +++ b/frontend/src/components/roles/RoleForm.tsx @@ -70,11 +70,7 @@ export const RoleForm: FC> = ({ }, [data, reset]); return ( - + diff --git a/frontend/src/components/subscribers/SubscriberForm.tsx b/frontend/src/components/subscribers/SubscriberForm.tsx index aa1e2529..675b1b3e 100644 --- a/frontend/src/components/subscribers/SubscriberForm.tsx +++ b/frontend/src/components/subscribers/SubscriberForm.tsx @@ -61,11 +61,7 @@ export const SubscriberForm: FC> = ({ }, [data, reset]); return ( - + diff --git a/frontend/src/components/translations/TranslationForm.tsx b/frontend/src/components/translations/TranslationForm.tsx index a796c94b..e8b7936b 100644 --- a/frontend/src/components/translations/TranslationForm.tsx +++ b/frontend/src/components/translations/TranslationForm.tsx @@ -82,11 +82,7 @@ export const TranslationForm: FC> = ({ }; return ( - + {t("label.original_text")} diff --git a/frontend/src/components/users/EditUserForm.tsx b/frontend/src/components/users/EditUserForm.tsx index 71ee4187..8a59a93c 100644 --- a/frontend/src/components/users/EditUserForm.tsx +++ b/frontend/src/components/users/EditUserForm.tsx @@ -74,11 +74,7 @@ export const EditUserForm: FC> = ({ }, [reset, data?.user]); return ( - + diff --git a/frontend/src/components/users/InviteUserForm.tsx b/frontend/src/components/users/InviteUserForm.tsx index 68d677f0..3bcb0f17 100644 --- a/frontend/src/components/users/InviteUserForm.tsx +++ b/frontend/src/components/users/InviteUserForm.tsx @@ -62,11 +62,7 @@ export const InviteUserForm: FC> = ({ sendInvitation(params); return ( - + diff --git a/frontend/src/types/common/dialogs.types.ts b/frontend/src/types/common/dialogs.types.ts index 943c1c92..ca7a1075 100644 --- a/frontend/src/types/common/dialogs.types.ts +++ b/frontend/src/types/common/dialogs.types.ts @@ -151,8 +151,9 @@ export interface DialogProviderProps { // form dialog export interface FormDialogProps extends FormButtonsProps, - Omit, + Omit, DialogExtraOptions { + open?: boolean; title?: string; children?: React.ReactNode; }