add loading

This commit is contained in:
Philip Cheung 2024-10-08 11:07:54 +08:00
parent fee442a51d
commit eaabe01b4d
1 changed files with 15 additions and 23 deletions

View File

@ -91,23 +91,6 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
const [editorState, setEditorState] = useState<EditorState>(EditorState.createEmpty()); const [editorState, setEditorState] = useState<EditorState>(EditorState.createEmpty());
const [content, setContent] = useState<string>(''); 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({ const mutation = useMutation({
@ -128,6 +111,12 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
}) })
const onSubmit: SubmitHandler<AboutUsCreate> = (data) => { const onSubmit: SubmitHandler<AboutUsCreate> = (data) => {
if (isSubmitting) return
try {
if (data.image instanceof FileList && data.image.length > 0) { if (data.image instanceof FileList && data.image.length > 0) {
data.image = data.image[0] data.image = data.image[0]
} }
@ -135,8 +124,11 @@ const AddAboutUs = ({ isOpen, onClose }: AddAboutUsProps) => {
console.log(data) console.log(data)
} }
catch (error) {
console.error("Error:", error);
}
}
return ( return (
<> <>
<Modal <Modal