diff --git a/bbbeasy-frontend/src/components/RoomPresentations.tsx b/bbbeasy-frontend/src/components/RoomPresentations.tsx index af480f70..69853ab6 100644 --- a/bbbeasy-frontend/src/components/RoomPresentations.tsx +++ b/bbbeasy-frontend/src/components/RoomPresentations.tsx @@ -18,11 +18,13 @@ import React, { useState } from 'react'; import { Trans } from 'react-i18next'; +import { t } from 'i18next'; import { Card, Modal, Typography, Upload } from 'antd'; import { PlusOutlined } from '@ant-design/icons'; import { UploadFile } from 'antd/es/upload/interface'; import { RcFile, UploadProps } from 'antd/es/upload'; +import Notifications from "./Notifications"; const { Title } = Typography; @@ -72,7 +74,26 @@ const RoomPresentations = () => { setPreviewImage(file.url || (file.preview as string)); setPreviewOpen(true); }; - const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => setFileList(newFileList); + const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => + { + const validFormats = + [ + 'xls','xlsx','doc','docx','ppt', + 'pptx','odt','rtf','txt','ods', + 'odp','avi','mpg','mp3','pdf', + 'jpg','jpeg','png','svg' + ]; + const lastFile= newFileList[(newFileList.length)-1]; + const filename = lastFile.name; + if(filename.includes(".")){ + const fileFormat = filename.substring(filename.indexOf('.')+1); + if(validFormats.includes(fileFormat)){ + setFileList(newFileList); + return; + } + } + Notifications.openNotificationWithIcon('error', t('invalid_format')); + } const uploadButton = (
diff --git a/bbbeasy-frontend/src/locale/ar-TN.json b/bbbeasy-frontend/src/locale/ar-TN.json index 3784559b..9537abf7 100644 --- a/bbbeasy-frontend/src/locale/ar-TN.json +++ b/bbbeasy-frontend/src/locale/ar-TN.json @@ -389,7 +389,8 @@ "no_recordings": "لا توجد تسجيلات", "no_rooms": "لا يوجد غرف دردشة", "no_presets": "لا توجد إعدادات مسبقة", - "no_labels": "لا توجد علامات", - "no_data": "لا توجد بيانات" + "no_data": "لا توجد بيانات", + "invalid_format": "تنسيق هذا الملف غير مناسب" + } diff --git a/bbbeasy-frontend/src/locale/en-US.json b/bbbeasy-frontend/src/locale/en-US.json index ff24fee3..590a4b4d 100644 --- a/bbbeasy-frontend/src/locale/en-US.json +++ b/bbbeasy-frontend/src/locale/en-US.json @@ -397,5 +397,6 @@ "no_rooms": "No Rooms", "no_presets": "No Presets", "no_labels": "No labels", - "no_data": "No Data" + "no_data": "No Data", + "invalid_format": "invalid file format" } diff --git a/bbbeasy-frontend/src/locale/fr-FR.json b/bbbeasy-frontend/src/locale/fr-FR.json index 8701c291..eae3bde4 100644 --- a/bbbeasy-frontend/src/locale/fr-FR.json +++ b/bbbeasy-frontend/src/locale/fr-FR.json @@ -391,5 +391,6 @@ "no_rooms": "Aucune Salle", "no_presets": "Aucun Préréglage", "no_labels": "Aucun Label", - "no_data": "Aucune donnée" + "no_data": "Aucune donnée", + "invalid_format": "Format de fichier invalide" }