fix: update effect dependencies to use fetcher.data for improved error handling in dialogs
This commit is contained in:
parent
e7ef7177ca
commit
7b840ce5cd
@ -37,7 +37,7 @@ export const DialogUpload = () => {
|
|||||||
|
|
||||||
setUploadedFile(fetcher.data.uploadData.data.file_url)
|
setUploadedFile(fetcher.data.uploadData.data.file_url)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher.data])
|
||||||
|
|
||||||
const handleChange = async function (event: ChangeEvent<HTMLInputElement>) {
|
const handleChange = async function (event: ChangeEvent<HTMLInputElement>) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|||||||
@ -36,8 +36,8 @@ export const DialogLogin = () => {
|
|||||||
const { handleSubmit } = formMethods
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ export const DialogLogin = () => {
|
|||||||
setIsSubscribeOpen(true)
|
setIsSubscribeOpen(true)
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher.data])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogNews
|
<DialogNews
|
||||||
|
|||||||
@ -58,15 +58,15 @@ export const DialogRegister = () => {
|
|||||||
const { handleSubmit, control } = formMethods
|
const { handleSubmit, control } = formMethods
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsRegisterOpen(false)
|
setIsRegisterOpen(false)
|
||||||
setIsSuccessOpen('register')
|
setIsSuccessOpen('register')
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher.data])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogNews
|
<DialogNews
|
||||||
|
|||||||
@ -43,15 +43,15 @@ export const DialogSubscribePlan = () => {
|
|||||||
const { handleSubmit } = formMethods
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsSubscribeOpen(false)
|
setIsSubscribeOpen(false)
|
||||||
setIsSuccessOpen('payment')
|
setIsSuccessOpen('payment')
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher.data])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogNews
|
<DialogNews
|
||||||
|
|||||||
@ -27,12 +27,12 @@ export const AdminLoginPage = () => {
|
|||||||
const { handleSubmit } = formMethods
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher.data])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-dvh min-w-dvw flex-col items-center justify-center space-y-8">
|
<div className="flex min-h-dvh min-w-dvw flex-col items-center justify-center space-y-8">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user