add loading
This commit is contained in:
parent
fee442a51d
commit
eaabe01b4d
|
@ -91,23 +91,6 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
|
|||
const [editorState, setEditorState] = useState<EditorState>(EditorState.createEmpty());
|
||||
const [content, setContent] = useState<string>('');
|
||||
|
||||
// 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,6 +111,12 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
|
|||
})
|
||||
|
||||
const onSubmit: SubmitHandler<AboutUsCreate> = (data) => {
|
||||
|
||||
|
||||
if (isSubmitting) return
|
||||
|
||||
try {
|
||||
|
||||
if (data.image instanceof FileList && data.image.length > 0) {
|
||||
data.image = data.image[0]
|
||||
}
|
||||
|
@ -135,8 +124,11 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
|
|||
console.log(data)
|
||||
|
||||
}
|
||||
catch (error) {
|
||||
console.error("Error:", error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
|
|
Loading…
Reference in New Issue