diff --git a/frontend/src/components/AboutUs/AddAboutUs.tsx b/frontend/src/components/AboutUs/AddAboutUs.tsx index 700bb19..94db65e 100644 --- a/frontend/src/components/AboutUs/AddAboutUs.tsx +++ b/frontend/src/components/AboutUs/AddAboutUs.tsx @@ -91,23 +91,6 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { const [editorState, setEditorState] = useState(EditorState.createEmpty()); const [content, setContent] = useState(''); - // const validateFiles = (value: File) => { - // if (typeof value === 'string') return true; - - - // const fsMb = value.size / (1024 * 1024) - // const MAX_FILE_SIZE = 10 - // if (fsMb > MAX_FILE_SIZE) { - // return 'Max file size 10mb' - // } - - // return true - // } - - - // type FormValues = { - // file_: FileList - // } const mutation = useMutation({ @@ -128,15 +111,24 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { }) const onSubmit: SubmitHandler = (data) => { - if (data.image instanceof FileList && data.image.length > 0) { - data.image = data.image[0] + + + if (isSubmitting) return + + try { + + if (data.image instanceof FileList && data.image.length > 0) { + data.image = data.image[0] + } + mutation.mutate(data) + console.log(data) + + } + catch (error) { + console.error("Error:", error); } - mutation.mutate(data) - console.log(data) } - - return ( <>