Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

Commit fbbda4a

Browse files
Sandeep KumarSandeep Kumar
authored andcommitted
added email validation
1 parent 0abb8b8 commit fbbda4a

1 file changed

Lines changed: 52 additions & 14 deletions

File tree

fe/src/comps/Intro/Intro-Mid.jsx

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Steps, Collapse, Button, Form, Input } from "antd";
1+
import { Steps, Collapse, Button, Form, Input, Spin } from "antd";
2+
import { LoadingOutlined } from "@ant-design/icons";
23
import { useState } from "react";
34
import airtable from "../../components/airtable";
45
import Schema from "async-validator";
@@ -7,6 +8,21 @@ Schema.warning = function () {}; // to avoid async validator warning
78
const { Step } = Steps;
89
const { Panel } = Collapse;
910

11+
async function emailValidationAPI(data) {
12+
try {
13+
const response = await fetch(
14+
`https://api.quickemailverification.com/v1/verify?email=${data.Email}&apikey=23d78e221b6a02915f263674a89d7cfeeb4084621225b7a8b9b0ec050204`
15+
);
16+
const responseJson = await response.json();
17+
console.log(responseJson);
18+
return responseJson;
19+
} catch (error) {
20+
return {
21+
safe_to_send: "false",
22+
};
23+
}
24+
}
25+
1026
const IAMData = {
1127
"IAM Role - Assume Role Policy":
1228
"The IAM Role requires an Assume Role Policy that allows access to SEGG AWS Account to assume the role",
@@ -48,11 +64,25 @@ const stepData = {
4864
</>
4965
),
5066
};
67+
const failedEmailValidation = (
68+
<>
69+
<br />
70+
<br />
71+
<span> Please Enter A Valid Email Id !</span>
72+
</>
73+
);
74+
const registrationButton = (
75+
<Button type="primary" htmlType="submit">
76+
Register
77+
</Button>
78+
);
5179

5280
const IntroMid = () => {
5381
const [width, setWidth] = useState("120px");
5482
const [panel, setPanel] = useState("registerPart1");
5583
const [activeKey, setActiveKey] = useState("");
84+
const [registerButton, setRegisterButton] = useState(registrationButton);
85+
const [emailValidationMessage, setEmailValidationMessage] = useState("");
5686

5787
const changeWidth = () => {
5888
if (width === "120px") {
@@ -65,13 +95,26 @@ const IntroMid = () => {
6595
}, 200);
6696
}
6797
};
68-
const formStyle = {};
6998

7099
const formUpdate = (values) => {
71-
console.log(values);
72-
airtable(values);
73-
setPanel("registerPart2");
74-
setActiveKey("2");
100+
setRegisterButton(<Spin indicator={<LoadingOutlined />} />);
101+
setEmailValidationMessage(<></>);
102+
try {
103+
emailValidationAPI(values).then((data) => {
104+
if (data.safe_to_send === "true") {
105+
airtable(values);
106+
setPanel("registerPart2");
107+
setActiveKey("2");
108+
setRegisterButton(registrationButton);
109+
} else {
110+
setEmailValidationMessage(failedEmailValidation);
111+
setRegisterButton(registrationButton);
112+
}
113+
});
114+
} catch (error) {
115+
setEmailValidationMessage(failedEmailValidation);
116+
setRegisterButton(registrationButton);
117+
}
75118
};
76119

77120
const panelJSX = {
@@ -91,7 +134,6 @@ const IntroMid = () => {
91134
<Form.Item
92135
label="Name"
93136
name="Name"
94-
style={formStyle}
95137
rules={[
96138
{
97139
required: true,
@@ -103,7 +145,6 @@ const IntroMid = () => {
103145
</Form.Item>
104146
<Form.Item
105147
label="Email"
106-
style={formStyle}
107148
name="Email"
108149
rules={[
109150
{
@@ -120,7 +161,6 @@ const IntroMid = () => {
120161
</Form.Item>
121162
<Form.Item
122163
label="Organisation"
123-
style={formStyle}
124164
name="Organisation"
125165
rules={[
126166
{
@@ -133,7 +173,6 @@ const IntroMid = () => {
133173
</Form.Item>
134174
<Form.Item
135175
label="Designation"
136-
style={formStyle}
137176
name="Designation"
138177
rules={[
139178
{
@@ -145,10 +184,9 @@ const IntroMid = () => {
145184
<Input />
146185
</Form.Item>
147186

148-
<Form.Item style={formStyle}>
149-
<Button type="primary" htmlType="submit">
150-
Register
151-
</Button>
187+
<Form.Item>
188+
{registerButton}
189+
{emailValidationMessage}
152190
</Form.Item>
153191
</Form>
154192
</Panel>

0 commit comments

Comments
 (0)