Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
sujata
/
advithconsulting.io-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit d8928221
authored
2025-10-30 12:11:36 +0530
by
Aman
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
changes in form done
1 parent
fba5ef14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
222 additions
and
160 deletions
components/reuseables/CallBackRequest.js
container/Contact/ContactForm.js
components/reuseables/CallBackRequest.js
View file @
d892822
...
@@ -20,95 +20,128 @@ const CallBackRequest = () => {
...
@@ -20,95 +20,128 @@ const CallBackRequest = () => {
// email api
// email api
const
router
=
useRouter
();
const
router
=
useRouter
();
const
onSubmit
=
async
(
data
)
=>
{
// const onSubmit = async (data) => {
// const leadData = {
// mobilenumber: data.Mobile,
// email: data.Email,
// message: data.AdditionalMessage || "",
// name: data.Name,
// service: data.service,
// source: data.source,
// };
// console.log(leadData, "form-data");
// const strapiData = {
// data: {
// Name: data.Name,
// Phone: data.Mobile,
// Email: data.Email,
// Service: data.service,
// Source: data.source,
// },
// };
// console.log("strapiData", strapiData);
// const config = {
// headers: {
// "Content-Type": "multipart/form-data",
// },
// };
// try {
// const response = await axios.post(
// `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/service-forms`,
// strapiData,
// config
// );
// if (response.status === 200) {
// console.log("Form submited to strapi");
// }
// } catch (error) {
// console.error(error);
// }
// await fetch("/api/submitZoho", {
// method: "POST",
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify(leadData),
// });
// try {
// const response = await axios.post("/api/homegooglesheet", leadData, {
// headers: {
// "Content-Type": "application/json",
// },
// });
// console.log("Google Sheet API response:", response?.data);
// if (response.data.success) {
// router.push("/thank-you");
// sendEmaill(data);
// }
// } catch (error) {
// console.error(
// "Error submitting to Google Sheet API:",
// error.response ? error.response.data : error.message
// );
// }
// reset();
// };
// const sendEmaill = (data) => {
// fetch("/api/sendEmailHome", {
// method: "POST",
// headers: {
// Accept: "application/json, text/plain, */*",
// "Content-Type": "application/json",
// },
// body: JSON.stringify(data),
// })
// .then((response) => {
// console.log("response received", response);
// if (response.status === 200) {
// console.log("response succeeded");
// } else {
// console.log("response failed");
// }
// })
// .catch((error) => {
// console.error(error);
// });
// };
const
onSubmit
=
async
(
data
)
=>
{
const
leadData
=
{
const
leadData
=
{
mobilenumber
:
data
.
Mobile
,
mobilenumber
:
data
.
Mobile
,
email
:
data
.
Email
,
email
:
data
.
Email
,
message
:
data
.
AdditionalMessage
||
""
,
message
:
data
.
AdditionalMessage
||
""
,
name
:
data
.
Name
,
name
:
data
.
Name
,
service
:
data
.
service
,
service
:
data
.
service
,
source
:
data
.
source
,
source
:
data
.
source
||
"Home page form"
,
};
};
console
.
log
(
leadData
,
"form-data"
);
const
strapiData
=
{
console
.
log
(
"Submitting to Zoho:"
,
leadData
);
data
:
{
Name
:
data
.
Name
,
Phone
:
data
.
Mobile
,
Email
:
data
.
Email
,
Service
:
data
.
service
,
Source
:
data
.
source
,
},
};
console
.
log
(
"strapiData"
,
strapiData
);
const
config
=
{
headers
:
{
"Content-Type"
:
"multipart/form-data"
,
},
};
try
{
try
{
const
response
=
await
axios
.
post
(
const
response
=
await
fetch
(
"/api/submitZoho"
,
{
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/service-forms`
,
method
:
"POST"
,
strapiData
,
headers
:
{
"Content-Type"
:
"application/json"
},
config
body
:
JSON
.
stringify
(
leadData
),
);
if
(
response
.
status
===
200
)
{
console
.
log
(
"Form submited to strapi"
);
}
}
catch
(
error
)
{
console
.
error
(
error
);
}
await
fetch
(
"/api/submitZoho"
,
{
method
:
"POST"
,
headers
:
{
"Content-Type"
:
"application/json"
},
body
:
JSON
.
stringify
(
leadData
),
});
try
{
const
response
=
await
axios
.
post
(
"/api/homegooglesheet"
,
leadData
,
{
headers
:
{
"Content-Type"
:
"application/json"
,
},
});
});
console
.
log
(
"Google Sheet API response:"
,
response
?.
data
);
if
(
response
.
data
.
success
)
{
if
(
response
.
ok
)
{
console
.
log
(
"Form submitted successfully to Zoho"
);
router
.
push
(
"/thank-you"
);
router
.
push
(
"/thank-you"
);
sendEmaill
(
data
);
reset
();
}
else
{
console
.
error
(
"Zoho submission failed:"
,
response
.
status
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
console
.
error
(
"Error submitting form:"
,
error
);
"Error submitting to Google Sheet API:"
,
error
.
response
?
error
.
response
.
data
:
error
.
message
);
}
}
reset
();
};
const
sendEmaill
=
(
data
)
=>
{
fetch
(
"/api/sendEmailHome"
,
{
method
:
"POST"
,
headers
:
{
Accept
:
"application/json, text/plain, */*"
,
"Content-Type"
:
"application/json"
,
},
body
:
JSON
.
stringify
(
data
),
})
.
then
((
response
)
=>
{
console
.
log
(
"response received"
,
response
);
if
(
response
.
status
===
200
)
{
console
.
log
(
"response succeeded"
);
}
else
{
console
.
log
(
"response failed"
);
}
})
.
catch
((
error
)
=>
{
console
.
error
(
error
);
});
};
};
return
(
return
(
<>
<>
<
div
className
=
"free-quote-area ptb-100"
>
<
div
className
=
"free-quote-area ptb-100"
>
...
...
container/Contact/ContactForm.js
View file @
d892822
...
@@ -19,109 +19,135 @@ const ContactForm = () => {
...
@@ -19,109 +19,135 @@ const ContactForm = () => {
// email api
// email api
const
router
=
useRouter
();
const
router
=
useRouter
();
const
onSubmit
=
async
(
data
)
=>
{
//
const onSubmit = async (data) => {
const
finaldata
=
new
FormData
();
//
const finaldata = new FormData();
const
leadData
=
{
//
const leadData = {
mobilenumber
:
data
.
Mobile
,
//
mobilenumber: data.Mobile,
email
:
data
.
Email
,
//
email: data.Email,
message
:
data
.
AdditionalMessage
||
""
,
//
message: data.AdditionalMessage || "",
name
:
data
.
Name
,
//
name: data.Name,
company
:
data
.
Company
,
//
company: data.Company,
source
:
data
.
source
,
//
source: data.source,
};
//
};
// console.log("data", data);
//
// console.log("data", data);
const
strapiData
=
{
//
const strapiData = {
data
:
{
//
data: {
Name
:
data
.
Name
,
//
Name: data.Name,
Phone
:
data
.
Mobile
,
//
Phone: data.Mobile,
Email
:
data
.
Email
,
//
Email: data.Email,
Message
:
data
.
AdditionalMessage
||
""
,
//
Message: data.AdditionalMessage || "",
Company
:
data
.
Company
,
//
Company: data.Company,
Source
:
data
.
source
,
//
Source: data.source,
},
//
},
};
//
};
// console.log("strapiData", strapiData);
// finaldata.append("data", JSON.stringify(strapiData));
// console.log("formvalue", finaldata);
// // console.log(leadData, "form-data");
console
.
log
(
"strapiData"
,
strapiData
);
// // strapi
// const config = {
// headers: {
// "Content-Type": "multipart/form-data",
// },
// };
finaldata
.
append
(
"data"
,
JSON
.
stringify
(
strapiData
));
// await fetch("/api/submitZoho", {
console
.
log
(
"formvalue"
,
finaldata
);
// method: "POST",
// console.log(leadData, "form-data");
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify(leadData),
// });
// strapi
// try {
const
config
=
{
// const response = await axios.post(
headers
:
{
// `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/contact-forms`,
"Content-Type"
:
"multipart/form-data"
,
// strapiData,
},
// config
};
// );
// if (response.status === 200) {
// console.log("Form submited to strapi");
// }
// } catch (error) {
// console.error(error);
// }
// try {
// const response = await axios.post("/api/googlesheetapi", leadData, {
// headers: {
// "Content-Type": "application/json",
// },
// });
// console.log("Google Sheet API response:", response?.data);
// if (response.data.success) {
// router.push("/thank-you");
// sendEmaill(data);
// }
// } catch (error) {
// console.error(
// "Error submitting to Google Sheet API:",
// error.response ? error.response.data : error.message
// );
// }
await
fetch
(
"/api/submitZoho"
,
{
// const sendEmaill = (data) => {
method
:
"POST"
,
// fetch("/api/sendEmail", {
headers
:
{
"Content-Type"
:
"application/json"
},
// method: "POST",
body
:
JSON
.
stringify
(
leadData
),
// headers: {
});
// Accept: "application/json, text/plain, */*",
// "Content-Type": "application/json",
// },
// body: JSON.stringify(data),
// })
// .then((response) => {
// console.log("response received", response);
// if (response.status === 200) {
// console.log("response succeeded");
// } else {
// console.log("response failed");
// }
// })
// .catch((error) => {
// console.error(error);
// });
// };
// sendEmaill(data);
// reset();
// };
try
{
const
onSubmit
=
async
(
data
)
=>
{
const
response
=
await
axios
.
post
(
const
leadData
=
{
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/contact-forms`
,
mobilenumber
:
data
.
Mobile
,
strapiData
,
email
:
data
.
Email
,
config
message
:
data
.
AdditionalMessage
||
""
,
);
name
:
data
.
Name
,
if
(
response
.
status
===
200
)
{
company
:
data
.
Company
,
console
.
log
(
"Form submited to strapi"
);
source
:
data
.
source
,
}
};
}
catch
(
error
)
{
console
.
error
(
error
);
console
.
log
(
"Submitting to Zoho:"
,
leadData
);
}
try
{
try
{
const
response
=
await
axios
.
post
(
"/api/googlesheetapi"
,
leadData
,
{
const
response
=
await
fetch
(
"/api/submitZoho"
,
{
headers
:
{
method
:
"POST"
,
"Content-Type"
:
"application/json"
,
headers
:
{
"Content-Type"
:
"application/json"
}
,
}
,
body
:
JSON
.
stringify
(
leadData
)
,
});
});
console
.
log
(
"Google Sheet API response:"
,
response
?.
data
);
if
(
response
.
data
.
success
)
{
if
(
response
.
ok
)
{
console
.
log
(
"Form submitted successfully to Zoho"
);
router
.
push
(
"/thank-you"
);
router
.
push
(
"/thank-you"
);
sendEmaill
(
data
);
reset
();
}
else
{
console
.
error
(
"Zoho submission failed:"
,
response
.
status
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
console
.
error
(
"Error submitting form:"
,
error
);
"Error submitting to Google Sheet API:"
,
error
.
response
?
error
.
response
.
data
:
error
.
message
);
}
}
const
sendEmaill
=
(
data
)
=>
{
fetch
(
"/api/sendEmail"
,
{
method
:
"POST"
,
headers
:
{
Accept
:
"application/json, text/plain, */*"
,
"Content-Type"
:
"application/json"
,
},
body
:
JSON
.
stringify
(
data
),
})
.
then
((
response
)
=>
{
console
.
log
(
"response received"
,
response
);
if
(
response
.
status
===
200
)
{
console
.
log
(
"response succeeded"
);
}
else
{
console
.
log
(
"response failed"
);
}
})
.
catch
((
error
)
=>
{
console
.
error
(
error
);
});
};
sendEmaill
(
data
);
reset
();
};
};
return
(
return
(
...
@@ -138,8 +164,8 @@ const ContactForm = () => {
...
@@ -138,8 +164,8 @@ const ContactForm = () => {
<
span
className
=
"sub-title"
>
SEND
MESSAGE
<
/span
>
<
span
className
=
"sub-title"
>
SEND
MESSAGE
<
/span
>
<
Heading
heading
=
"Write to Us!"
/>
<
Heading
heading
=
"Write to Us!"
/>
<
p
>
<
p
>
Let
’
s
connect
to
explore
how
Advith
’
s
customized
solutions
can
drive
your
business
forward
.
Let
’
s
connect
to
explore
how
Advith
’
s
customized
solutions
can
drive
your
business
forward
.
<
/p
>
<
/p
>
<
form
onSubmit
=
{
handleSubmit
(
onSubmit
)}
>
<
form
onSubmit
=
{
handleSubmit
(
onSubmit
)}
>
...
@@ -209,7 +235,10 @@ const ContactForm = () => {
...
@@ -209,7 +235,10 @@ const ContactForm = () => {
placeholder
=
"Mobile"
placeholder
=
"Mobile"
className
=
"text-dark form-control"
className
=
"text-dark form-control"
onInput
=
{(
e
)
=>
{
onInput
=
{(
e
)
=>
{
e
.
target
.
value
=
e
.
target
.
value
.
replace
(
/
[^
0-9
]
/g
,
''
);
e
.
target
.
value
=
e
.
target
.
value
.
replace
(
/
[^
0-9
]
/g
,
""
);
}}
}}
{...
register
(
"Mobile"
,
{
{...
register
(
"Mobile"
,
{
required
:
"Enter Your Mobile Number"
,
required
:
"Enter Your Mobile Number"
,
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment