import { Calendar } from "lucide-react"; import Link from "next/link"; import { redirect } from "next/navigation"; import { getPayments } from "@/actions/payment"; import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import type { Payment } from "@/lib/backend-types"; import { cn } from "@/lib/utils"; import { tryCatch } from "@/utils/tryCatch"; import Pagination from "./pagination"; import { Badge } from "./ui/badge"; import { Button } from "./ui/button"; import { Separator } from "./ui/separator"; export async function PaymentsTable({ searchParams, }: { searchParams: Promise<{ query: string; page: number; sortBy: string; }>; }) { const query = (await searchParams)?.query || ""; const [error, payments] = await tryCatch(getPayments()); if (error) { if (error.message.includes("Unauthorized")) { redirect("/auth/signin"); } else { return
{JSON.stringify(error, null, 2)}; } } const { data, meta } = payments; return (