add loading
This commit is contained in:
		| @@ -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,15 +111,24 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => { | ||||
|   }) | ||||
|  | ||||
|   const onSubmit: SubmitHandler<AboutUsCreate> = (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 ( | ||||
|     <> | ||||
|       <Modal | ||||
|   | ||||
		Reference in New Issue
	
	Block a user