2025-10-12 17:42:17 +00:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
import Image from "next/image";
|
|
|
|
|
|
|
|
|
|
import { GreenBtn } from "@/components/ui/Buttons";
|
|
|
|
|
|
2026-02-11 20:45:37 +00:00
|
|
|
import { useAppDispatch } from "@/redux/hooks";
|
|
|
|
|
import { setShowInput } from "@/redux/slices/headerSlice";
|
2025-10-12 17:42:17 +00:00
|
|
|
import { baseAPI } from "@/lib/API";
|
|
|
|
|
import { NewsPageType } from "@/lib/types/NewsPage.type";
|
2026-02-11 20:45:37 +00:00
|
|
|
import { Link } from "@/i18n/navigation";
|
2025-10-12 17:42:17 +00:00
|
|
|
import { BreadCrumbs } from "@/components/ui/bread-crumbs";
|
|
|
|
|
import { Title } from "@/components/ui/title";
|
|
|
|
|
import Loader from "@/components/ui/Loader";
|
2026-02-11 20:45:37 +00:00
|
|
|
import { useLocale, useTranslations } from "next-intl";
|
2025-10-12 17:42:17 +00:00
|
|
|
|
|
|
|
|
export default function SingleNewsPage({ params }: { params: { id: string } }) {
|
|
|
|
|
const dispatch = useAppDispatch();
|
2026-02-11 20:45:37 +00:00
|
|
|
const locale = useLocale();
|
|
|
|
|
const t = useTranslations("news");
|
2025-10-12 17:42:17 +00:00
|
|
|
|
|
|
|
|
const [newsItemData, setNewsItemData] = React.useState<NewsPageType>();
|
|
|
|
|
|
|
|
|
|
const fetchData = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(`${baseAPI}news/${params.id}`, {
|
|
|
|
|
headers: {
|
2026-02-11 20:45:37 +00:00
|
|
|
"Accept-Language": locale,
|
2025-10-12 17:42:17 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error("error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
|
|
|
|
|
setNewsItemData(data);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
fetchData();
|
|
|
|
|
dispatch(setShowInput(false));
|
2026-02-11 20:45:37 +00:00
|
|
|
}, [locale]);
|
2025-10-12 17:42:17 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="section-mb w-full">
|
2026-02-11 20:45:37 +00:00
|
|
|
<BreadCrumbs second={t("title")} path="/news" third={t("article")} />
|
2025-10-12 17:42:17 +00:00
|
|
|
{newsItemData ? (
|
|
|
|
|
<div className="mb-5">
|
|
|
|
|
<Title text={newsItemData.data.title} />
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<Loader />
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center justify-between mb-[44px] md:mb-8">
|
|
|
|
|
<p className="text-[#919599]">{newsItemData?.data.published_at}</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{newsItemData?.data?.featured_images?.[0]?.path && (
|
|
|
|
|
<Image
|
|
|
|
|
height={480}
|
|
|
|
|
width={833}
|
|
|
|
|
src={newsItemData?.data.featured_images[0]?.path || ""}
|
|
|
|
|
alt="картинка"
|
|
|
|
|
className="mb-6 max-h-[480px] object-cover w-full"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<div className="mb-[50px]">
|
|
|
|
|
{newsItemData && (
|
|
|
|
|
<>
|
|
|
|
|
<div
|
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
|
__html: newsItemData.data.content_html,
|
|
|
|
|
}}
|
|
|
|
|
className="text-[16px] flex flex-col gap-6 leading-[150%] seperate-news-html"
|
|
|
|
|
/>
|
|
|
|
|
<br />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Link href="/news" className="flex justify-center">
|
2026-02-11 20:45:37 +00:00
|
|
|
<GreenBtn text={t("allNews")} px />
|
2025-10-12 17:42:17 +00:00
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|