fix: replace disabled state with loading state for buttons in upload and category forms
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user