turkmen-expo/components/shared/Partners.tsx

78 lines
2.0 KiB
TypeScript
Raw Normal View History

2025-10-12 17:42:17 +00:00
"use client";
import React, { useEffect, useState } from "react";
import Image from "next/image";
import { Swiper, SwiperSlide } from "swiper/react";
import { Autoplay, Pagination } from "swiper/modules";
import { PartnersType } from "@/lib/types/PartnersData.type";
import { baseAPI } from "@/lib/API";
import { useTranslations, useLocale } from "next-intl";
2025-10-12 17:42:17 +00:00
import { Title } from "../ui/title";
export const Partners = () => {
const locale = useLocale();
const t = useTranslations("home");
2025-10-12 17:42:17 +00:00
const [partnersData, setPartnersData] = useState<PartnersType>();
const fetchPartners = async () => {
try {
const res = await fetch(`${baseAPI}partners`, {
headers: {
"Accept-Language": locale,
2025-10-12 17:42:17 +00:00
},
});
const data = await res.json();
setPartnersData(data);
} catch (error) {
console.error(error);
}
};
useEffect(() => {
fetchPartners();
}, [locale]);
2025-10-12 17:42:17 +00:00
return (
<section className="container">
<div className="mb-[40px]">
<Title text={t("partners")} />
2025-10-12 17:42:17 +00:00
</div>
<div className="flex items-center">
<Swiper
modules={[Pagination, Autoplay]}
loop
slidesPerView={5}
autoplay={{ delay: 0 }}
spaceBetween={30}
speed={7000}
breakpoints={{
1024: { slidesPerView: 5 },
768: { slidesPerView: 4.5 },
630: { slidesPerView: 3.5 },
300: { slidesPerView: 2 },
}}
>
{partnersData &&
partnersData.data.map((logo, i) => (
<SwiperSlide key={i} className="h-[63px] w-fit overflow-hidden">
<a href={logo.link} target="_blank">
<Image
height={200}
width={200}
src={logo.images[0].path}
alt="logo"
className="h-full w-full object-contain"
/>
</a>
</SwiperSlide>
))}
</Swiper>
</div>
</section>
);
};