fix: add file type check

This commit is contained in:
Emnaghz 2024-10-07 17:50:46 +01:00
parent e0dd09d491
commit 1d72732fad
3 changed files with 15 additions and 2 deletions

View File

@ -99,6 +99,17 @@ const AttachmentUploader: FC<FileUploadProps> = ({
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('.*', ''))
);
if (!isValidType) {
toast.error(t("message.invalid_file_type"));
return;
}
uploadAttachment(file);
}
}

View File

@ -104,7 +104,8 @@
"title_length_exceeded": "You have reached the maximum length",
"no_label_found": "No label found",
"code_is_required": "Language code is required",
"text_is_required": "Text is required"
"text_is_required": "Text is required",
"invalid_file_type": "Invalid file type"
},
"menu": {
"terms": "Terms of Use",

View File

@ -104,7 +104,8 @@
"title_length_exceeded": "Vous avez atteint la longueur maximale",
"no_label_found": "Aucune étiquette trouvée",
"code_is_required": "Le code est requis",
"text_is_required": "Texte requis"
"text_is_required": "Texte requis",
"invalid_file_type": "Type de fichier invalide"
},
"menu": {
"terms": "Conditions d'utilisation",