From 535b4f0f8eac6b44dc481f02fc7d371b0ff2d357 Mon Sep 17 00:00:00 2001 From: Emnaghz Date: Wed, 9 Oct 2024 16:32:08 +0100 Subject: [PATCH] fix: content reload after import --- .../app-components/attachment/AttachmentInput.tsx | 2 +- .../attachment/AttachmentUploader.tsx | 13 +++++++------ .../src/app-components/dialogs/DeleteDialog.tsx | 11 ++++++++++- .../src/components/contents/ContentImportDialog.tsx | 10 ++++++++-- frontend/src/components/contents/index.tsx | 9 +++++++-- frontend/src/hooks/useDialog.tsx | 2 +- 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/frontend/src/app-components/attachment/AttachmentInput.tsx b/frontend/src/app-components/attachment/AttachmentInput.tsx index 82f3938b..28c7a5ec 100644 --- a/frontend/src/app-components/attachment/AttachmentInput.tsx +++ b/frontend/src/app-components/attachment/AttachmentInput.tsx @@ -46,7 +46,7 @@ const AttachmentInput = forwardRef( ref, ) => { const hasPermission = useHasPermission(); - const handleChange = (attachment: IAttachment | null) => { + const handleChange = (attachment?: IAttachment | null) => { onChange && onChange(attachment?.id || null, attachment?.type || null); }; diff --git a/frontend/src/app-components/attachment/AttachmentUploader.tsx b/frontend/src/app-components/attachment/AttachmentUploader.tsx index 3587367b..2a7f75a4 100644 --- a/frontend/src/app-components/attachment/AttachmentUploader.tsx +++ b/frontend/src/app-components/attachment/AttachmentUploader.tsx @@ -65,7 +65,7 @@ export type FileUploadProps = { imageButton?: boolean; accept: string; enableMediaLibrary?: boolean; - onChange?: (data: IAttachment | null) => void; + onChange?: (data?: IAttachment | null) => void; }; const AttachmentUploader: FC = ({ @@ -99,15 +99,16 @@ const AttachmentUploader: FC = ({ const file = event.target.files.item(0); if (file) { - const acceptedTypes = accept.split(','); - const isValidType = acceptedTypes.some((type) => - file.type === type || file.name.endsWith(type.replace('.*', '')) + const acceptedTypes = accept.split(","); + const isValidType = acceptedTypes.some( + (type) => + file.type === type || file.name.endsWith(type.replace(".*", "")), ); if (!isValidType) { toast.error(t("message.invalid_file_type")); - -return; + + return; } uploadAttachment(file); diff --git a/frontend/src/app-components/dialogs/DeleteDialog.tsx b/frontend/src/app-components/dialogs/DeleteDialog.tsx index f9114992..d5097939 100644 --- a/frontend/src/app-components/dialogs/DeleteDialog.tsx +++ b/frontend/src/app-components/dialogs/DeleteDialog.tsx @@ -43,7 +43,16 @@ export const DeleteDialog: FC = ({ -