Skip to content

Commit 0e1c3ad

Browse files
committed
do error correction
1 parent 68fa364 commit 0e1c3ad

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/components/Blog/BlogFormManager.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { useShowNotification } from "@/hooks/useShowNotification";
2222
import { NotificationMessage } from "@/components/@extended/NotificationMessage";
2323
import { useDispatch, useSelector } from "react-redux";
2424
import AnimateButton from "@/components/@extended/AnimateButton";
25-
import { insertBlog, updateBlog } from "@/store/blogs/blogSlice";
25+
import { insertBlog, updateBlog } from "@/store/blogs/blogSlice";
2626
import { fetchCategories } from "@/store/categories/categorySlice";
2727
import { useLocation, useNavigate } from "react-router";
2828
const blogDataSchema = Yup.object().shape({
@@ -94,7 +94,7 @@ export default function BlogFormManager() {
9494
})
9595
.catch((error) => {
9696
setSubmitting(false);
97-
if (error?.errors) {
97+
if (error?.errors && Object.keys(error.errors).length > 0) {
9898
setErrors(error.errors);
9999
} else {
100100
setStatus({
@@ -119,7 +119,7 @@ export default function BlogFormManager() {
119119
})
120120
.catch((error) => {
121121
setSubmitting(false);
122-
if (error?.errors) {
122+
if (error?.errors && Object.keys(error.errors).length > 0) {
123123
setErrors(error.errors);
124124
} else {
125125
setStatus({
@@ -132,7 +132,7 @@ export default function BlogFormManager() {
132132
}
133133
} catch (error) {
134134
setSubmitting(false);
135-
if (error?.errors) {
135+
if (error?.errors && Object.keys(error.errors).length > 0) {
136136
setErrors(error.errors);
137137
} else {
138138
setStatus({

src/components/Category/FormManager.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function FormManager({ recordData, closeModal, onSuccess }) {
7272
})
7373
.catch((error) => {
7474
setSubmitting(false);
75-
if (error?.errors) {
75+
if (error?.errors && Object.keys(error.errors).length > 0) {
7676
setErrors(error.errors);
7777
} else {
7878
setStatus({
@@ -100,7 +100,7 @@ export default function FormManager({ recordData, closeModal, onSuccess }) {
100100
})
101101
.catch((error) => {
102102
setSubmitting(false);
103-
if (error?.errors) {
103+
if (error?.errors && Object.keys(error.errors).length > 0) {
104104
setErrors(error.errors);
105105
} else {
106106
setStatus({
@@ -114,7 +114,7 @@ export default function FormManager({ recordData, closeModal, onSuccess }) {
114114
}
115115
} catch (error) {
116116
setSubmitting(false);
117-
if (error?.errors) {
117+
if (error?.errors && Object.keys(error.errors).length > 0) {
118118
setErrors(error.errors);
119119
} else {
120120
setStatus({

src/components/Profile/ChangePasswordForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const ChangePasswordForm = () => {
3636
resetForm();
3737
})
3838
.catch((error) => {
39-
if (error?.errors) {
39+
if (error?.errors && Object.keys(error.errors).length > 0) {
4040
// Set API validation errors on the form fields
4141
setErrors(error.errors);
4242
}

src/components/Profile/ProfileForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const ProfileForm = () => {
4343
.unwrap() // Ensure error handling with `createAsyncThunk`
4444
.then(() => {})
4545
.catch((error) => {
46-
if (error?.errors) {
46+
if (error?.errors && Object.keys(error.errors).length > 0) {
4747
// Set API validation errors on the form fields
4848
setErrors(error.errors);
4949
}

src/pages/Auth/LoginPage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const LoginPage = () => {
4949
showNotification(response?.message, "success");
5050
})
5151
.catch((error) => {
52-
if (error?.errors) {
52+
if (error?.errors && Object.keys(error.errors).length > 0) {
5353
// Set API validation errors on the form fields
5454
setErrors(error.errors);
5555
}

src/pages/Auth/RegisterPage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const RegisterPage = () => {
5757
});
5858
})
5959
.catch((error) => {
60-
if (error?.errors) {
60+
if (error?.errors && Object.keys(error.errors).length > 0) {
6161
// Set API validation errors on the form fields
6262
setErrors(error.errors);
6363
}

0 commit comments

Comments
 (0)