Hard coded the URL
This commit is contained in:
@@ -1,68 +1,64 @@
|
|||||||
import Footer from "@/components/Footer";
|
import Footer from "@/components/Footer";
|
||||||
import Navbar from "@/components/Navbar";
|
import Navbar from "@/components/Navbar";
|
||||||
import Title from "@/components/Title";
|
import Title from "@/components/Title";
|
||||||
import { Contact } from "@/types/contact";
|
import {Contact} from "@/types/contact";
|
||||||
import translation from "@/translation/agentcontacts.json";
|
import translation from "@/translation/agentcontacts.json";
|
||||||
type Language = "en" | "ar";
|
type Language = "en" | "ar";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
country: string;
|
country: string;
|
||||||
page: string;
|
page: string;
|
||||||
language: Language;
|
language: Language;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCountryManagers(country: string, language: Language = "en") {
|
async function getCountryManagers(country: string, language: Language = "en") {
|
||||||
const res = await fetch(
|
const res = await fetch(`https://platform.encoach.com/api/users/agents/${country}?language=${language}`);
|
||||||
`${process.env.NEXT_PUBLIC_APP_URL}/api/users/agents/${country}?language=${language}`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error("Failed to fetch contacts");
|
throw new Error("Failed to fetch contacts");
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateStaticParamsHelper(language: Language = "en") {
|
export async function generateStaticParamsHelper(language: Language = "en") {
|
||||||
const contacts = (await fetch(
|
const contacts = (await fetch(`https://platform.encoach.com/api/users/agents?language=${language}`).then((res) => res.json())) as Contact[];
|
||||||
`${process.env.NEXT_PUBLIC_APP_URL}/api/users/agents?language=${language}`
|
return contacts.map(({key}) => ({
|
||||||
).then((res) => res.json())) as Contact[];
|
country: key.toLowerCase().replaceAll(" ", ""),
|
||||||
return contacts.map(({ key }) => ({
|
}));
|
||||||
country: key.toLowerCase().replaceAll(" ", ""),
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
export async function AgentContacts({ language, page, country }: Props) {
|
export async function AgentContacts({language, page, country}: Props) {
|
||||||
const contact = (await getCountryManagers(country, language)) as Contact;
|
const contact = (await getCountryManagers(country, language)) 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} />
|
||||||
|
|
||||||
<section className="bg-mti-purple h-full w-full p-8 text-center text-white md:p-16">
|
<section className="bg-mti-purple h-full w-full p-8 text-center text-white md:p-16">
|
||||||
<div className="flex h-full w-full flex-col items-center justify-center">
|
<div className="flex h-full w-full flex-col items-center justify-center">
|
||||||
<Title>{`${contact.label} Contacts`}</Title>
|
<Title>{`${contact.label} Contacts`}</Title>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="bg-white h-full w-full p-8 md:p-16 flex gap-16 justify-center flex-wrap">
|
<section className="bg-white h-full w-full p-8 md:p-16 flex gap-16 justify-center flex-wrap">
|
||||||
{contact.entries.map((entry) => (
|
{contact.entries.map((entry) => (
|
||||||
<div key={entry.name}>
|
<div key={entry.name}>
|
||||||
<h2>
|
<h2>
|
||||||
<strong>{translation.name[language]}: </strong>
|
<strong>{translation.name[language]}: </strong>
|
||||||
{entry.name}
|
{entry.name}
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
<strong>{translation.number[language]}: </strong>
|
<strong>{translation.number[language]}: </strong>
|
||||||
{entry.number}
|
{entry.number}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<strong>{translation.email[language]}: </strong>
|
<strong>{translation.email[language]}: </strong>
|
||||||
{entry.email}
|
{entry.email}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</section>
|
</section>
|
||||||
<Footer language={language} />
|
<Footer language={language} />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user