"use client";
import { footerL, footerR } from "@/constans";
import Logo from "@/app/component/Logo";
import Link from "next/link";
// Icons
import Linkedin from "../../icons/Linkedin";
import Telegram from "../../icons/Telegram";
import Whatsapp from "../../icons/Whatsapp";
import Instagram from "../../icons/Instagram";
import LocationF from "../../icons/LocationF";
import CalendarAddF from "../../icons/CalendarAddF";
import StethoscopeF from "../../icons/StethoscopeF";
import LogoNamad from "./LogoNamad";
import HeadMenu from "./menu/HeadMenu";
import ListMenu from "./menu/ListMenu";
import { useState } from "react";
import { isRootCity } from "@/lib/rootCity";
// روی دامنهٔ ریشه (nobat724.com) شهری در کار نیست، پس همان «شهر شما» میماند؛
// روی دامنهٔ هر شهر، نام همان شهر مینشیند. لینک نسبی است تا هر دامنه به ریشهٔ
// خودش برود و کاربر بین دامنهها پرت نشود.
const buildHead = (matchedCity) => {
const cityName = isRootCity(matchedCity) ? null : matchedCity?.name;
return [
{
icon: ,
text: cityName ? `جستجوی پزشک در شهر ${cityName}` : "جستجوی پزشک در شهر شما",
link: "/",
},
{ icon: , text: "نوبت گیری سریع و آسان", link: "/" },
{
icon: ,
text: "مدیریت کلینیک با کلینیک پرو",
link: "https://clinic-pro.ir/",
},
];
};
function buildSocialUrl(name, value) {
if (!value) return null;
if (/^https?:\/\//i.test(value)) return value;
const handle = value.replace(/^@/, "").replace(/^\+/, "");
switch (name) {
case "instagram":
return `https://instagram.com/${handle}`;
case "telegram":
return `https://t.me/${handle}`;
case "whatsapp":
// wa.me needs international format: 09xx… → 989xx…
return `https://wa.me/${handle.replace(/\D/g, "").replace(/^0/, "98")}`;
default:
return value;
}
}
function Footer({ matchedCity }) {
const socialMedias = [
{
icon: ,
name: "instagram",
},
{
icon: ,
name: "telegram",
},
{
icon: ,
name: "whatsapp",
},
];
const [openMenu, setOpenMenu] = useState({
right: false,
left: false,
});
const changeMenu = (name) =>
setOpenMenu({ ...openMenu, [name]: !openMenu[name] });
return (
{buildHead(matchedCity).map((item, idx) => (
))}
{/* Right */}
{/* Icon */}
{matchedCity?.footer_description}
{/* Center */}
{/* Left */}
همراه با ما باشید:
{socialMedias.map((item, idx) => {
const url = buildSocialUrl(item.name, matchedCity?.social_media?.[item.name]);
return (
-
{url ? (
{item.icon}
) : (
{item.icon}
)}
);
})}
{matchedCity?.footerDisclaimer}
);
}
export default Footer;