fix: streamline error handling in dialogs by removing unnecessary return statements

This commit is contained in:
Ardeman
2025-03-15 17:33:21 +08:00
parent 7b840ce5cd
commit d767055bdb
12 changed files with 14 additions and 24 deletions
-2
View File
@@ -31,12 +31,10 @@ export const DialogProfile = () => {
useEffect(() => {
if (!fetcher.data?.success && fetcher.data?.message) {
toast.error(fetcher.data.message)
return
}
if (fetcher.data?.success) {
setEditProfile(false)
return
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetcher.data])
+3 -2
View File
@@ -32,10 +32,11 @@ export const DialogUpload = () => {
useEffect(() => {
if (!fetcher.data?.success && fetcher.data?.message) {
toast.error(fetcher.data.message)
return
}
setUploadedFile(fetcher.data.uploadData.data.file_url)
if (fetcher.data?.success) {
setUploadedFile(fetcher.data.uploadData.data.file_url)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetcher.data])
+3 -1
View File
@@ -41,7 +41,9 @@ export const DialogLogin = () => {
return
}
setIsLoginOpen(false)
if (fetcher.data?.success) {
setIsLoginOpen(false)
}
if (fetcher.data?.user.subscribe?.subscribe_plan?.code === 'basic') {
setIsSubscribeOpen(true)
+4 -3
View File
@@ -60,11 +60,12 @@ export const DialogRegister = () => {
useEffect(() => {
if (!fetcher.data?.success && fetcher.data?.message) {
toast.error(fetcher.data.message)
return
}
setIsRegisterOpen(false)
setIsSuccessOpen('register')
if (fetcher.data?.success) {
setIsRegisterOpen(false)
setIsSuccessOpen('register')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetcher.data])
+4 -3
View File
@@ -45,11 +45,12 @@ export const DialogSubscribePlan = () => {
useEffect(() => {
if (!fetcher.data?.success && fetcher.data?.message) {
toast.error(fetcher.data.message)
return
}
setIsSubscribeOpen(false)
setIsSuccessOpen('payment')
if (fetcher.data?.success) {
setIsSubscribeOpen(false)
setIsSuccessOpen('payment')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetcher.data])