"use client"; import { Counter } from "@/components/Counter"; import httpClient from "@/request/api"; import { endPoints } from "@/request/links"; import { useQuery } from "@tanstack/react-query"; import { useTranslations } from "next-intl"; import { useEffect, useState } from "react"; interface Statistics { id: number; number: number; hint: string; description: string; } export function Statistics() { const t = useTranslations(); const stats = [ { id: 1, number: 25, hint: "+", description: t("home.statistics.experience"), }, { id: 2, number: 450, hint: "+", description: t("home.statistics.projectsCompleted"), }, { id: 3, number: 99, hint: "+", description: t("home.statistics.trainedSpecialists"), }, { id: 4, number: 93, hint: "%", description: t("home.statistics.trustedClients"), }, ]; const [stat, setStat] = useState(stats); const { data } = useQuery({ queryKey: ["statistics"], queryFn: () => httpClient(endPoints.statistics), select: (data) => data?.data?.results, }); useEffect(() => { data && setStat(data); }, [data]); return (
{stat.map((stat, index) => (
{/* Number and Symbol */}
{stat.hint}
{/* Label */}

{stat.description}

))}
); }