"use client"; import { getPaymentHistory } from "@/pages/finance/lib/api"; import formatPrice from "@/shared/lib/formatPrice"; import { Button } from "@/shared/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/shared/ui/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/shared/ui/table"; import { useQuery } from "@tanstack/react-query"; import { ChevronLeft, ChevronRightIcon, Loader2 } from "lucide-react"; import { useState } from "react"; import { useTranslation } from "react-i18next"; export function PaymentHistory() { const { t } = useTranslation(); const [page, setPage] = useState(1); const { data, isLoading, isError } = useQuery({ queryKey: ["payment-history", page], queryFn: () => getPaymentHistory({ page, page_size: 10 }), }); if (isLoading) return (
); if (isError || !data) return (

Xatolik yuz berdi. Qayta urinib ko‘ring.

); const history = data.data; return ( {t("To'lovlar tarixi")} ID {t("Agentlik")} {t("Telefon")} {t("Summasi")} {t("Izoh")} {t("Buxgalter")} {history.data.results.map((item) => ( {item.travel_agency.custom_id} {item.travel_agency.name} {item.travel_agency.phone} {formatPrice(item.amount, true)} {item.note || "-"} {item.accountant.first_name} {item.accountant.last_name} ))}
{/* Pagination */}

{t("Sahifa")} {history.data.current_page} /{" "} {history.data.total_pages}

); }