"use client"; import { useTranslations } from "next-intl"; import { DataTable } from "@/components/admin/data-table"; import Link from "@/components/link"; import { Badge } from "@/components/ui/badge"; import type { DataTableColumn, PaginatedResult } from "@/types/common"; export interface TransactionRow { id: number; payer: string; payerId: number; amount: string; package: string; status: string; statusKind: "ok" | "danger" | "neutral"; transactionId: string; date: string; } function statusVariant( kind: TransactionRow["statusKind"], ): "default" | "destructive" | "secondary" { if (kind === "ok") return "default"; if (kind === "danger") return "destructive"; return "secondary"; } export function TransactionsTable({ data, }: { data: PaginatedResult; }) { const t = useTranslations("pages.admin.transactions"); const columns: DataTableColumn[] = [ { key: "id", label: t("colId"), sortable: true }, { key: "payer", label: t("colPayer"), sortable: true, render: (_value, row) => ( {row.payer} ), }, { key: "amount", label: t("colAmount"), sortable: true }, { key: "package", label: t("colPackage"), sortable: true }, { key: "status", label: t("colStatus"), sortable: true, filterKey: "filter_status", filterOptions: [ { label: t("statusCompleted"), value: "paid" }, { label: t("statusPending"), value: "pending" }, { label: t("statusFailed"), value: "failed" }, ], render: (_value, row) => row.status ? ( {row.status} ) : ( — ), }, { key: "transactionId", label: t("colTransaction") }, { key: "date", label: t("colDate"), sortable: true }, ]; return ( ); }