import { Review } from "../../../services/content/types"; import TestimonialCard from "../../../components/TestimonialCard"; import { useQuery } from "@tanstack/react-query"; import { DataCacheKey, staleTime } from "../../../global/constants"; import { startLoading, stopLoading, } from "../../../features/loading/loadingSlice"; import { contentApi } from "../../../apis/contentApi"; import { useAppDispatch } from "../../../hooks/useRedux"; import { useTranslation } from "react-i18next"; const HomeTestimonial = () => { const dispatch = useAppDispatch(); const { t } = useTranslation(); const { data: loadReviewData = [] } = useQuery({ queryKey: [DataCacheKey.REVIEWS], queryFn: async (): Promise => { try { dispatch(startLoading({})); const res = await contentApi.LoadReview({ pageNumber: 0, pageSize: 10, isFeatured: true, }); return res.data.reviews as Review[]; } catch (error) { console.error(error); return []; // 🔴 bắt buộc } finally { dispatch(stopLoading()); } }, staleTime: staleTime, }); return (

{t("whatUs")}
{t("sayAboutUs")}

{t("overMillionSatisfiedCustomers")}

{loadReviewData.map((item, i) => ( ))}
{loadReviewData .slice() .reverse() .map((item, i) => ( ))}
{[...loadReviewData, ...loadReviewData, ...loadReviewData].map( (item, i) => (
) )}
); }; export default HomeTestimonial;