Commit fba5ef14 by Aman

annual-reports page added

1 parent 4253a47a
......@@ -61,37 +61,11 @@ const CallBackRequest = () => {
console.error(error);
}
// zoho form
// try {
// const zohoFormUrl =
// "https://forms.zohopublic.in/services10/form/ContactUs/formperma/bJVh0UBQ6gjwfELMYAzkqMf5pfIyed3eJcjfSaEXmVg/htmlRecords/submit";
// const zohoForm = new FormData();
// zohoForm.append("zf_referrer_name", ""); // optional
// zohoForm.append("zf_redirect_url", ""); // optional
// zohoForm.append("zc_gad", ""); // optional
// zohoForm.append("Name_First", data.Name || "");
// zohoForm.append("Name_Last", "text"); // optional
// zohoForm.append("Email", data.Email || "");
// zohoForm.append("SingleLine", data.service || "");
// zohoForm.append("SingleLine1", data.Mobile || "");
// zohoForm.append("MultiLine", "text");
// zohoForm.append("SingleLine1", data.Mobile || "");
// await fetch(zohoFormUrl, {
// method: "POST",
// body: zohoForm,
// });
// console.log("✅ Submitted to Zoho Form");
// } catch (error) {
// console.error("❌ Zoho submission failed:", 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, {
......
......@@ -43,6 +43,8 @@ const ContactForm = () => {
},
};
console.log("strapiData", strapiData);
finaldata.append("data", JSON.stringify(strapiData));
......@@ -56,6 +58,14 @@ const ContactForm = () => {
},
};
await fetch("/api/submitZoho", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(leadData),
});
try {
const response = await axios.post(
`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/contact-forms`,
......@@ -86,6 +96,7 @@ const ContactForm = () => {
error.response ? error.response.data : error.message
);
}
const sendEmaill = (data) => {
fetch("/api/sendEmail", {
......
......@@ -49,6 +49,9 @@ const Footer = () => {
<li>
<Link href="/contact">Contact Us</Link>
</li>
<li>
<Link href="/annual-reports">Annual Reports</Link>
</li>
</ul>
</div>
</div>
......
import React from "react";
import PageBanner from "@/components/reuseables/PageBanner";
import { cleanImage } from "@/layout/imageHandling";
import axios from "axios";
import qs from "qs";
import Seo from "@/components/reuseables/Seo/Seo";
import Heading from "@/components/reuseables/Heading";
export default function Contact({ Contactpage, conversionData }) {
console.log("conatct", Contactpage);
console.log({Contactpage});
const banners = [
{
imageSrc: cleanImage(Contactpage?.Banner?.Image?.url),
pageTitle: Contactpage?.Banner?.Heading,
homePageUrl: "/",
homePageText: "Home",
activePageText: Contactpage?.Banner?.Heading,
},
];
const seo = Contactpage?.seo;
const Listing = Contactpage.Listing;
console.log({ Listing });
return (
<>
<Seo seo={seo} />
<PageBanner banners={banners} />
<div className="container py-5">
{Listing.map((item, index) => (
<div
key={item.id}
className={`card mb-3 border-0 ${
index !== Listing.length - 1 ? "border-bottom pb-2" : ""
}`}
style={{
borderBottomColor: "#dee2e6", // Bootstrap default border color
borderBottomWidth: index !== Listing.length - 1 ? "1px" : "0",
borderBottomStyle: "solid",
}}
>
<div className="card-body">
<div className="mb-4">
<Heading el="h2" heading={item.Title} />
</div>
{/* GRID layout */}
<div className="row">
{item.category.map((cat) => (
<div key={cat.id} className="col-12 col-md-4 mb-3">
<a
href={cleanImage(cat?.img?.url)}
download
target="_blank"
rel="noopener noreferrer"
className="text-decoration-underline d-flex gap-2 text-dark"
style={{ cursor: "pointer" }}
>
<p>{cat.name}</p> <span className="text-danger">(PDF)</span>
</a>
</div>
))}
</div>
</div>
</div>
))}
</div>
</>
);
}
export async function getServerSideProps() {
try {
const query1 = {
populate: [
"Banner.Image",
"seo",
"seo.metaImage",
"seo.schema",
"Listing",
"Listing.category",
"Listing.category.img",
],
};
const query2 = {
populate: ["conversion"],
};
const query1String = qs.stringify(query1, {
encodeValuesOnly: true,
});
const query12String = qs.stringify(query2, {
encodeValuesOnly: true,
});
const endpoint1 = `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/annual-reports?${query1String}`;
const endpoint2 = `${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/google-manger?${query12String}`;
// console.log(`Final url: ${endpoint1}`);
const [response1, response2] = await Promise.all([
axios.get(endpoint1),
axios.get(endpoint2),
]);
const Contactpage = response1.data.data;
const conversionData = response2.data.data;
return {
props: { Contactpage, conversionData },
};
} catch (error) {
console.log("Error", error);
}
}
export default async function handler(req, res) {
if (req.method !== "POST") {
return res.status(405).json({ error: "Method not allowed" });
}
try {
const zohoFormUrl =
"https://forms.zohopublic.in/services10/form/ContactUs/formperma/bJVh0UBQ6gjwfELMYAzkqMf5pfIyed3eJcjfSaEXmVg/htmlRecords/submit";
// Ensure values exist
const {
name = "",
email = "",
mobilenumber = "",
service = "",
// AdditionalMessage = "-",
message = "-",
} = req.body || {};
console.log(req.body);
// Build form data (URL encoded, required by Zoho)
const formData = new URLSearchParams();
formData.append("zf_referrer_name", "Website Contact Form");
formData.append("zf_redirect_url", ""); // leave blank if no redirect
formData.append("zc_gad", "");
formData.append("Name_First", name);
formData.append("Name_Last", "-");
formData.append("Email", email);
formData.append("SingleLine", service);
formData.append("SingleLine1", mobilenumber);
formData.append("MultiLine", message);
const zohoResponse = await fetch(zohoFormUrl, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: formData.toString(),
redirect: "manual", // prevents auto-following 302
});
// Zoho usually replies 302 (redirect), we treat that as success
if (zohoResponse.status === 200 || zohoResponse.status === 302) {
return res
.status(200)
.json({ success: true, status: zohoResponse.status });
} else {
const text = await zohoResponse.text();
console.error("Zoho response not OK:", zohoResponse.status, text);
return res.status(zohoResponse.status).json({
success: false,
status: zohoResponse.status,
message: text,
});
}
} catch (error) {
console.error("Zoho submission error:", error);
return res.status(500).json({ success: false, error: error.message });
}
}
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!