import "./MapSection.scss"; import Typography from "@/shared/ui/components/Typography/Typography"; import Paragraph from "@/shared/ui/components/Paragraph/Paragraph"; import MapSearch from "./MapSearch/MapSearch"; import dynamic from "next/dynamic"; import { apiInstance } from "@/shared/config/apiConfig"; import { IReport } from "@/shared/types/report-type"; import Switch from "./Switch/Switch"; import { ROAD_TYPES_COLORS } from "@/shared/variables/road-types"; import { useTranslations } from "next-intl"; import { getTranslations } from "next-intl/server"; const DynamicMap = dynamic(() => import("./HomeMap/HomeMap"), { ssr: false, }); interface IMapSectionProps { searchParams: { ["тип-дороги"]: string; ["поиск-на-карте"]: string; ["поиск-рейтинг"]: string; ["страница-рейтинга"]: string; }; } const MapSection: React.FC = async ({ searchParams, }: IMapSectionProps) => { const t = await getTranslations("home"); const getReports = async (categories: string) => { const res = await apiInstance( `/report/?category=${categories}` ); return res.data; }; const data = (await getReports(searchParams["тип-дороги"] || "1,2,3,4,5,6")) || []; const setCategories = (category: string) => { if (searchParams["тип-дороги"] === undefined) { const categories = ["1", "2", "3", "4", "5", "6"]; return categories.filter((cat) => cat !== category).join(","); } const categories = Array.from(searchParams["тип-дороги"]).filter( (part) => part !== "," ); if (categories.includes(category)) return categories.filter((cat) => cat !== category).join(","); categories.push(category); return categories.join(","); }; const ROAD_TYPES: Record = { 1: t("broken_roads"), 2: t("accident_hotspots"), 3: t("local_defects"), 4: t("repair_plans"), 5: t("repaired"), 6: t("fixed_local_defects"), }; return (
{t("road_map")} {t("latest_news")}
    {[1, 2, 3].map((sw) => (
  • {ROAD_TYPES[sw]}

  • ))}
    {[4, 5, 6].map((sw) => (
  • {ROAD_TYPES[sw]}

  • ))}
); }; export default MapSection;