Hard coded the URL
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
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";
|
||||||
|
|
||||||
@@ -12,9 +12,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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");
|
||||||
@@ -24,14 +22,12 @@ async function getCountryManagers(country: string, language: Language = "en") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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[];
|
|
||||||
return contacts.map(({ key }) => ({
|
|
||||||
country: key.toLowerCase().replaceAll(" ", ""),
|
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 (
|
||||||
|
|||||||
Reference in New Issue
Block a user