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
@@ -73,7 +73,6 @@ export const FormContentsPage = (properties: TProperties) => {
const { categoriesData: categories } = loaderData || {}
const { tagsData: tags } = loaderData || {}
const [error, setError] = useState<string>()
const [disabled, setDisabled] = useState(false)
const formMethods = useRemixForm<TContentSchema>({
mode: 'onSubmit',
@@ -100,12 +99,10 @@ export const FormContentsPage = (properties: TProperties) => {
useEffect(() => {
if (!fetcher.data?.success) {
setError(fetcher.data?.message)
setDisabled(false)
return
}
navigate('/lg-admin/contents')
setDisabled(true)
setError(undefined)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetcher])
@@ -144,7 +141,8 @@ export const FormContentsPage = (properties: TProperties) => {
containerClassName="flex-1"
/>
<Button
disabled={disabled}
isLoading={fetcher.state !== 'idle'}
disabled={fetcher.state !== 'idle'}
type="submit"
size="lg"
className="text-md h-[42px] rounded-md"