fix: replace disabled state with loading state for buttons in upload and category forms

This commit is contained in:
Ardeman
2025-03-11 06:13:03 +08:00
parent 66bc731b07
commit 6ec8e5f2a2
5 changed files with 13 additions and 22 deletions
+2 -4
View File
@@ -34,7 +34,6 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
},
})
const [error, setError] = useState<string>()
const [disabled, setDisabled] = useState(false)
const { handleSubmit, watch, setValue } = formMethods
const watchName = watch('name')
@@ -42,11 +41,9 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
useEffect(() => {
if (!fetcher.data?.success) {
setError(fetcher.data?.message)
setDisabled(false)
return
}
navigate('/lg-admin/subscribe-plan')
setDisabled(true)
setError(undefined)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetcher])
@@ -93,7 +90,8 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
containerClassName="flex-1"
/>
<Button
disabled={disabled}
disabled={fetcher.state !== 'idle'}
isLoading={fetcher.state !== 'idle'}
type="submit"
size="lg"
className="text-md h-[42px] rounded-md"