Updated the code to send the full page link
This commit is contained in:
@@ -16,7 +16,7 @@ interface PageProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getCountryManagers(country: string) {
|
async function getCountryManagers(country: string) {
|
||||||
const res = await fetch(`${process.env.NEXT_PUBLIC_APP_URL}/api/users/agents/${country}`);
|
const res = await fetch(`https://platform.encoach.com/api/users/agents/${country}`);
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error("Failed to fetch contacts");
|
throw new Error("Failed to fetch contacts");
|
||||||
@@ -26,7 +26,7 @@ async function getCountryManagers(country: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const contacts = await fetch(`${process.env.NEXT_PUBLIC_APP_URL}/api/users/agents`).then((res) => res.json()) as Contact[];
|
const contacts = (await fetch(`https://platform.encoach.com/api/users/agents`).then((res) => res.json())) as Contact[];
|
||||||
|
|
||||||
// down the line, this is required to be loaded from a CMS
|
// down the line, this is required to be loaded from a CMS
|
||||||
// for now, we'll just use a JSON file
|
// for now, we'll just use a JSON file
|
||||||
@@ -37,11 +37,8 @@ export async function generateStaticParams() {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({params: {country}, searchParams: {page = "/contacts", language = "en"}}: PageProps) {
|
||||||
params: { country },
|
const contact = (await getCountryManagers(country)) as Contact;
|
||||||
searchParams: { page = "/contacts", language = "en" },
|
|
||||||
}: PageProps) {
|
|
||||||
const contact = await getCountryManagers(country) as Contact;
|
|
||||||
return (
|
return (
|
||||||
<main className="text-mti-black flex h-screen w-full flex-col bg-white">
|
<main className="text-mti-black flex h-screen w-full flex-col bg-white">
|
||||||
<Navbar currentPage={page} language={language} />
|
<Navbar currentPage={page} language={language} />
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export default function App({ language, page }: Props) {
|
|||||||
},
|
},
|
||||||
subject: data.subject,
|
subject: data.subject,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
reportedFrom: window.location.href,
|
reportedFrom: window?.location.toString() || "",
|
||||||
status: "submitted",
|
status: "submitted",
|
||||||
date: new Date().toISOString(),
|
date: new Date().toISOString(),
|
||||||
description: data.description,
|
description: data.description,
|
||||||
@@ -90,10 +90,7 @@ export default function App({ language, page }: Props) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
<main
|
<main className="text-mti-black flex h-screen w-full flex-col bg-white" dir={language === "ar" ? "rtl" : "ltr"}>
|
||||||
className="text-mti-black flex h-screen w-full flex-col bg-white"
|
|
||||||
dir={language === "ar" ? "rtl" : "ltr"}
|
|
||||||
>
|
|
||||||
<Navbar currentPage={page} language={language} />
|
<Navbar currentPage={page} language={language} />
|
||||||
<section className="w-full bg-mti-purple text-white text-center p-8 md:p-16">
|
<section className="w-full bg-mti-purple text-white text-center p-8 md:p-16">
|
||||||
<div className="w-full h-full flex flex-col items-center justify-center">
|
<div className="w-full h-full flex flex-col items-center justify-center">
|
||||||
@@ -101,10 +98,7 @@ export default function App({ language, page }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section className="w-full bg-white text-center p-8 md:p-16 flex justify-center items-center gap-32">
|
<section className="w-full bg-white text-center p-8 md:p-16 flex justify-center items-center gap-32">
|
||||||
<form
|
<form onSubmit={handleSubmit(onSubmit)} className="form-control items-center gap-2 text-mti-black flex flex-col w-96">
|
||||||
onSubmit={handleSubmit(onSubmit)}
|
|
||||||
className="form-control items-center gap-2 text-mti-black flex flex-col w-96"
|
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
id="name"
|
id="name"
|
||||||
type="text"
|
type="text"
|
||||||
@@ -112,9 +106,7 @@ export default function App({ language, page }: Props) {
|
|||||||
{...register("name", {required: true})}
|
{...register("name", {required: true})}
|
||||||
className="input input-bordered md:w-full sm:w-1/2 max-w-md"
|
className="input input-bordered md:w-full sm:w-1/2 max-w-md"
|
||||||
/>
|
/>
|
||||||
{errors.name && errors.name.type === "required" && (
|
{errors.name && errors.name.type === "required" && <ErrorMessage message={translation.fieldRequired[language]} />}
|
||||||
<ErrorMessage message={translation.fieldRequired[language]} />
|
|
||||||
)}
|
|
||||||
<input
|
<input
|
||||||
id="email"
|
id="email"
|
||||||
placeholder={translation.email[language]}
|
placeholder={translation.email[language]}
|
||||||
@@ -122,12 +114,8 @@ export default function App({ language, page }: Props) {
|
|||||||
{...register("email", {required: true, pattern: /^\S+@\S+$/i})}
|
{...register("email", {required: true, pattern: /^\S+@\S+$/i})}
|
||||||
className="input input-bordered md:w-full sm:w-1/2 max-w-md"
|
className="input input-bordered md:w-full sm:w-1/2 max-w-md"
|
||||||
/>
|
/>
|
||||||
{errors.email && errors.email.type === "required" && (
|
{errors.email && errors.email.type === "required" && <ErrorMessage message={translation.fieldRequired[language]} />}
|
||||||
<ErrorMessage message={translation.fieldRequired[language]} />
|
{errors.email && errors.email.type === "pattern" && <ErrorMessage message={translation.invalidEmail[language]} />}
|
||||||
)}
|
|
||||||
{errors.email && errors.email.type === "pattern" && (
|
|
||||||
<ErrorMessage message={translation.invalidEmail[language]} />
|
|
||||||
)}
|
|
||||||
<input
|
<input
|
||||||
id="subject"
|
id="subject"
|
||||||
placeholder={translation.subject[language]}
|
placeholder={translation.subject[language]}
|
||||||
@@ -135,14 +123,8 @@ export default function App({ language, page }: Props) {
|
|||||||
{...register("subject", {required: true})}
|
{...register("subject", {required: true})}
|
||||||
className="input input-bordered md:w-full sm:w-1/2 max-w-md"
|
className="input input-bordered md:w-full sm:w-1/2 max-w-md"
|
||||||
/>
|
/>
|
||||||
{errors.subject && errors.subject.type === "required" && (
|
{errors.subject && errors.subject.type === "required" && <ErrorMessage message={translation.fieldRequired[language]} />}
|
||||||
<ErrorMessage message={translation.fieldRequired[language]} />
|
<select id="type" {...register("type", {required: true})} className="select select-bordered md:w-full sm:w-1/2 max-w-md">
|
||||||
)}
|
|
||||||
<select
|
|
||||||
id="type"
|
|
||||||
{...register("type", { required: true })}
|
|
||||||
className="select select-bordered md:w-full sm:w-1/2 max-w-md"
|
|
||||||
>
|
|
||||||
<option value="" disabled>
|
<option value="" disabled>
|
||||||
{translation.selectType[language]}
|
{translation.selectType[language]}
|
||||||
</option>
|
</option>
|
||||||
@@ -152,9 +134,7 @@ export default function App({ language, page }: Props) {
|
|||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.type && errors.type.type === "required" && (
|
{errors.type && errors.type.type === "required" && <ErrorMessage message={translation.fieldRequired[language]} />}
|
||||||
<ErrorMessage message={translation.fieldRequired[language]} />
|
|
||||||
)}
|
|
||||||
<textarea
|
<textarea
|
||||||
id="description"
|
id="description"
|
||||||
placeholder={translation.description[language]}
|
placeholder={translation.description[language]}
|
||||||
@@ -165,21 +145,10 @@ export default function App({ language, page }: Props) {
|
|||||||
{errors.description && errors.description.type === "required" && (
|
{errors.description && errors.description.type === "required" && (
|
||||||
<ErrorMessage message={translation.fieldRequired[language]} />
|
<ErrorMessage message={translation.fieldRequired[language]} />
|
||||||
)}
|
)}
|
||||||
<input
|
<input type="submit" className="btn" disabled={!isDirty || !isValid} value={translation.submit[language]} />
|
||||||
type="submit"
|
|
||||||
className="btn"
|
|
||||||
disabled={!isDirty || !isValid}
|
|
||||||
value={translation.submit[language]}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<Image
|
<Image src="/person_laptop_focus.jpg" alt="Contact Us" width={500} height={340} className="rounded-xl" />
|
||||||
src="/person_laptop_focus.jpg"
|
|
||||||
alt="Contact Us"
|
|
||||||
width={500}
|
|
||||||
height={340}
|
|
||||||
className="rounded-xl"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<Footer language={language} />
|
<Footer language={language} />
|
||||||
|
|||||||
Reference in New Issue
Block a user