import Footer from "@/components/Footer"; import Navbar from "@/components/Navbar"; import Title from "@/components/Title"; import {Contact} from "@/types/contact"; import translation from "@/translation/agentcontacts.json"; import CountryManagerContactsPage from "@/types/cms/countryManagerContacts"; type Language = "en" | "ar"; interface Props { country: string; page: string; language: Language; data: CountryManagerContactsPage; } async function getCountryManagers(country: string, language: Language = "en") { const res = await fetch(`https://platform.encoach.com/api/users/agents/${country}?language=${language}`); if (!res.ok) { throw new Error("Failed to fetch contacts"); } return res.json(); } export async function generateStaticParamsHelper(language: Language = "en") { const contacts = (await fetch(`https://platform.encoach.com/api/users/agents?language=${language}`).then((res) => res.json())) as Contact[]; return contacts.map(({key}) => ({ country: key.toLowerCase().replaceAll(" ", ""), })); } export async function AgentContacts({language, page, country, data}: Props) { const contact = (await getCountryManagers(country, language)) as Contact; return (
{`${contact.label} Contacts`}
{contact.entries.map((entry) => (

{data.Name}: {entry.name}

{data.Number}: {entry.number}

{data.Email}: {entry.email}

))}
); }