fix: add loading state to buttons in forms and update button styles

This commit is contained in:
Ardeman
2025-03-11 06:00:49 +08:00
parent a45a6fb87e
commit 8cddc82031
5 changed files with 25 additions and 22 deletions
+2 -4
View File
@@ -24,7 +24,6 @@ export const FormLogin = () => {
} = useNewsContext()
const fetcher = useFetcher()
const [error, setError] = useState<string>()
const [disabled, setDisabled] = useState(false)
const formMethods = useRemixForm<TLoginSchema>({
mode: 'onSubmit',
@@ -37,11 +36,9 @@ export const FormLogin = () => {
useEffect(() => {
if (!fetcher.data?.success) {
setError(fetcher.data?.message)
setDisabled(false)
return
}
setDisabled(true)
setError(undefined)
setIsLoginOpen(false)
@@ -95,7 +92,8 @@ export const FormLogin = () => {
</div>
<Button
disabled={disabled}
isLoading={fetcher.state !== 'idle'}
disabled={fetcher.state !== 'idle'}
type="submit"
className="w-full rounded-md py-2"
>