feat: replace error state handling with toast in login, register, and subscribe dialogs

This commit is contained in:
Ardeman
2025-03-15 17:25:08 +08:00
parent 4c3a143338
commit e7ef7177ca
4 changed files with 12 additions and 31 deletions
+3 -7
View File
@@ -1,5 +1,6 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { useEffect, useState } from 'react'
import { useEffect } from 'react'
import toast from 'react-hot-toast'
import { Link, useFetcher } from 'react-router'
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
import { z } from 'zod'
@@ -22,13 +23,12 @@ export const AdminLoginPage = () => {
fetcher,
resolver: zodResolver(loginSchema),
})
const [error, setError] = useState<string>()
const { handleSubmit } = formMethods
useEffect(() => {
if (!fetcher.data?.success) {
setError(fetcher.data?.message)
toast.error(fetcher.data?.message)
return
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -72,10 +72,6 @@ export const AdminLoginPage = () => {
type="password"
/>
{error && (
<div className="text-sm text-red-500 capitalize">{error}</div>
)}
{/* Lupa Kata Sandi */}
<div className="mb-4 flex justify-between">
<span className="text-gray-600">Lupa Kata Sandi?</span>