diff --git a/frontend/public/locales/en/translation.json b/frontend/public/locales/en/translation.json index 9811b52b..3a45f541 100644 --- a/frontend/public/locales/en/translation.json +++ b/frontend/public/locales/en/translation.json @@ -443,6 +443,7 @@ "mb": "MB", "gb": "GB", "or": "OR", + "uploading_file": "Uploading file", "click_or_dragndrop_to_upload": "Click or Drag & Drop to upload a file", "button_block_message_label": "What would you like to know about us ?", "menu": "Menu", diff --git a/frontend/public/locales/fr/translation.json b/frontend/public/locales/fr/translation.json index d06616c7..6eaa8162 100644 --- a/frontend/public/locales/fr/translation.json +++ b/frontend/public/locales/fr/translation.json @@ -444,6 +444,7 @@ "mb": "Mo", "gb": "Go", "or": "Ou", + "uploading_file": "Téléchargement du fichier", "click_or_dragndrop_to_upload": "Cliquez ou faîtes un Drag & Drop pour charger un fichier", "button_block_message_label": "Que souhaitez-vous savoir sur nous ?", "menu": "Menu", diff --git a/frontend/src/app-components/attachment/AttachmentUploader.tsx b/frontend/src/app-components/attachment/AttachmentUploader.tsx index 2a7f75a4..7cd22126 100644 --- a/frontend/src/app-components/attachment/AttachmentUploader.tsx +++ b/frontend/src/app-components/attachment/AttachmentUploader.tsx @@ -18,6 +18,8 @@ import { useTranslate } from "@/hooks/useTranslate"; import { EntityType } from "@/services/types"; import { IAttachment } from "@/types/attachment.types"; +import LoadingIcon from "../icons/LoadingIcon"; + import { AttachmentDialog } from "./AttachmentDialog"; import AttachmentThumbnail from "./AttachmentThumbnail"; @@ -78,12 +80,15 @@ const AttachmentUploader: FC = ({ ); const { t } = useTranslate(); const [isDragOver, setIsDragOver] = useState(false); + const [isUploading, setIsUploading] = useState(false); const { toast } = useToast(); const { mutateAsync: uploadAttachment } = useUpload(EntityType.ATTACHMENT, { onError: () => { + setIsUploading(false); toast.error(t("message.upload_failed")); }, onSuccess: (data) => { + setIsUploading(false); toast.success(t("message.success_save")); setAttachment(data); onChange && onChange(data); @@ -95,6 +100,7 @@ const AttachmentUploader: FC = ({ e.preventDefault(); }; const handleChange = (event: ChangeEvent) => { + setIsUploading(true); if (event.target.files && event.target.files.length > 0) { const file = event.target.files.item(0); @@ -120,11 +126,13 @@ const AttachmentUploader: FC = ({ const file = event.dataTransfer.files.item(0); if (file) { + setIsUploading(true); uploadAttachment(file); } } }; + // Add a newline before the return statement return ( = ({ alignItems="center" sx={{ padding: "20px" }} > - {attachment ? ( + {isUploading ? ( + <> + + {t("label.uploading_file")} + + ) : attachment ? ( & { + size?: number; + color?: string; + } +> = ({ size = 50, color = "#000", ...rest }) => { + return ( + + + + + + + + + + + + + + ); +}; + +export default LoadingIcon;