diff --git a/src/app/contacts/[country]/page.tsx b/src/app/contacts/[country]/page.tsx new file mode 100644 index 0000000..b7eb476 --- /dev/null +++ b/src/app/contacts/[country]/page.tsx @@ -0,0 +1,78 @@ +import Footer from "@/components/Footer"; +import Navbar from "@/components/Navbar"; +import Title from "@/components/Title"; +import contacts from "../../../contacts.json"; + +interface Contact { + key: string; + label: string; + entries: { + name: string; + number: string; + email: string; + }[]; +} + +type Language = "en" | "ar"; + +interface PageProps { + params: { + country: string; + }; + searchParams: { + page: string; + language: Language; + }; +} + +export function generateStaticParams() { + // down the line, this is required to be loaded from a CMS + // for now, we'll just use a JSON file + + // do not forget the actually render this as multiple languages + return contacts.map(({ key }) => ({ + country: key.toLowerCase().replaceAll(" ", ""), + })); +} + +export default function Page({ + params: { country }, + searchParams: { page = "/contacts", language = "en" }, +}: PageProps) { + // this approach will not be viable later on when we have multiple languages + // or use the data from the server + // replace this with a fetch to the CMS + const contact = contacts.find(({ key }) => key === country) as Contact; + + return ( +
+ + +
+
+ {`${contact.label} Contacts`} +
+
+ +
+ {contact.entries.map((entry) => ( +
+

+ Name: + {entry.name} +

+

+ Number: + {entry.number} +

+

+ Email: + {entry.email} +

+
+ ))} +
+
+ ); +} diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index c779b09..5ace748 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -4,169 +4,269 @@ import Link from "next/link"; import Image from "next/image"; import clsx from "clsx"; -import {BsList, BsXLg} from "react-icons/bs"; -import {Fragment, useEffect, useState} from "react"; -import {Dialog, Menu, Transition} from "@headlessui/react"; -import {useRouter} from "next/navigation"; +import { BsList, BsXLg } from "react-icons/bs"; +import { Fragment, useEffect, useState } from "react"; +import { Dialog, Menu, Transition } from "@headlessui/react"; +import { useRouter } from "next/navigation"; import translation from "@/translation/navbar.json"; +import contacts from "@/contacts.json"; const items = [ - {page: "/", key: "home"}, - {page: "/services", key: "services"}, - {page: "/price", key: "price"}, - {page: "/about", key: "about"}, - {page: "/history", key: "history"}, - {page: "/contact", key: "contact"}, + { page: "/", key: "home" }, + { page: "/services", key: "services" }, + { page: "/price", key: "price" }, + { page: "/about", key: "about" }, + { page: "/history", key: "history" }, + { page: "/contact", key: "contact" }, + { + key: "country_manager", + page: "/contacts", + entries: contacts.map((data) => ({ + key: data.key, + label: data.label, + })), + }, ]; -export default function Navbar({currentPage, language}: {currentPage: string; language: "en" | "ar"}) { - const [isOpen, setIsOpen] = useState(false); +export default function Navbar({ + currentPage, + language, +}: { + currentPage: string; + language: "en" | "ar"; +}) { + const [isOpen, setIsOpen] = useState(false); + return ( + <> +
+ + EnCoach logo + +
+ {items.map((item) => + item.entries ? ( +
+ + {translation[item.key as keyof typeof translation][language]} + +
    + {item.entries?.map((innerEntry) => ( +
  • + + {innerEntry.label} + +
  • + ))} +
+
+ ) : ( + + {(translation as any)[item.key][language]} + + ) + )} +
+
+ + {translation.platform[language]} + + + {translation.join[language]} + + {language === "ar" ? ( + + EN + + ) : ( + + AR + + )} +
+
- return ( - <> -
- - EnCoach logo - -
- {items.map((item) => ( - - {(translation as any)[item.key][language]} - - ))} -
-
- - {translation.platform[language]} - - - {translation.join[language]} - - {language === "ar" ? ( - - EN - - ) : ( - - AR - - )} -
-
+ + setIsOpen(false)} + > + +
+ - - setIsOpen(false)}> - -
- +
+
+ + + + + EnCoach logo + +
+ {language === "ar" ? ( + + EN + + ) : ( + + AR + + )} +
setIsOpen(false)} + tabIndex={0} + > + setIsOpen(false)} + /> +
+
+
+
+ {items.map((item) => ( + + {(translation as any)[item.key][language]} + + ))} + + {translation.join[language]} + + + {translation.platform[language]} + +
+
+
+
+
+
+
-
-
- - - - - EnCoach logo - -
- {language === "ar" ? ( - - EN - - ) : ( - - AR - - )} -
setIsOpen(false)} tabIndex={0}> - setIsOpen(false)} /> -
-
-
-
- {items.map((item) => ( - - {(translation as any)[item.key][language]} - - ))} - - {translation.join[language]} - - - {translation.platform[language]} - -
-
-
-
-
-
-
- -
- - EnCoach logo - -
- {language === "ar" ? ( - - EN - - ) : ( - - AR - - )} -
setIsOpen(true)}> - setIsOpen(true)} /> -
-
-
- - ); +
+ + EnCoach logo + +
+ {language === "ar" ? ( + + EN + + ) : ( + + AR + + )} +
setIsOpen(true)}> + setIsOpen(true)} /> +
+
+
+ + ); } diff --git a/src/contacts.json b/src/contacts.json new file mode 100644 index 0000000..f69e645 --- /dev/null +++ b/src/contacts.json @@ -0,0 +1,36 @@ +[ + { + "label": "Egypt", + "key": "egypt", + "entries": [ + { + "name": "Modern Technology", + "number": "+226578480830", + "email": "egypt@encoach.com" + } + ] + }, + { + "label": "Oman", + "key": "oman", + "entries": [ + { + "name": "Smartway education", + "number": "+9689944094", + "email": "oman@encoach.com" + }, + { "name": "MTI", "number": "+9687445609", "email": "mti@encoach.com" } + ] + }, + { + "label": "Saudi Arabia", + "key": "saudiarabia", + "entries": [ + { + "name": "Edutrach services", + "number": "+96658499347", + "email": "edu@encoach.com" + } + ] + } +] diff --git a/src/translation/navbar.json b/src/translation/navbar.json index be1a8e0..5df3a4a 100644 --- a/src/translation/navbar.json +++ b/src/translation/navbar.json @@ -30,5 +30,9 @@ "join": { "en": "Sign up", "ar": "انضم إلينا" + }, + "country_manager": { + "en": "Country Manager", + "ar": "المدير المحلي" } -} \ No newline at end of file +}