Skip to content

Commit ce6ad18

Browse files
authored
Email valid check added in staffform (#1554)
1 parent fc10931 commit ce6ad18

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

epictrack-web/src/components/staff/StaffForm.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import positionService from "../../services/positionService";
1717
const schema = yup.object().shape({
1818
email: yup
1919
.string()
20-
.email()
20+
.email("Invalid email address")
2121
.required("Email is required")
2222
.test({
2323
name: "checkDuplicateEmail",
@@ -26,7 +26,9 @@ const schema = yup.object().shape({
2626
test: async (value, { parent }) => {
2727
if (value) {
2828
const result = await staffService.validateEmail(value, parent["id"]);
29-
return !(result.data as never)["exists"];
29+
if (result.status === 200) {
30+
return !(result.data as never)["exists"];
31+
}
3032
}
3133
return true;
3234
},

0 commit comments

Comments
 (0)