From cf2869a69aca2e81fa270594b9baf19ac4f87146 Mon Sep 17 00:00:00 2001 From: Forge Date: Wed, 25 Mar 2026 08:40:03 +0800 Subject: [PATCH] feat: remittances web page with status badges and collector info --- app/(app)/remittances/page.tsx | 96 +++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 19 deletions(-) diff --git a/app/(app)/remittances/page.tsx b/app/(app)/remittances/page.tsx index b5bbf49..b71ea35 100644 --- a/app/(app)/remittances/page.tsx +++ b/app/(app)/remittances/page.tsx @@ -1,43 +1,101 @@ 'use client'; -import { Card, CardContent, CardHeader } from '@/components/ui/card'; +import { useState } from 'react'; +import { useQuery } from '@tanstack/react-query'; +import { Card, CardContent } from '@/components/ui/card'; +import { Skeleton } from '@/components/ui/skeleton'; import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, + Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; +import { api } from '@/lib/api'; +import { format } from 'date-fns'; + +interface Remittance { + id: string; + totalAmount: number; + status: string; + notes?: string; + createdAt: string; + collectedBy?: { firstName: string; lastName: string }; + confirmedBy?: { firstName: string; lastName: string }; +} + +const STATUS_COLORS: Record = { + PENDING: 'bg-yellow-100 text-yellow-700', + CONFIRMED: 'bg-emerald-100 text-emerald-700', + REJECTED: 'bg-red-100 text-red-700', +}; export default function RemittancesPage() { + const [page, setPage] = useState(1); + const limit = 20; + + const { data, isLoading } = useQuery({ + queryKey: ['remittances', page], + queryFn: async () => { + const res = await api.get(`/api/v1/remittances?page=${page}&limit=${limit}`); + return res.data; + }, + }); + + const items: Remittance[] = Array.isArray(data) ? data : (data?.data ?? data?.items ?? []); + const total = (data as any)?.meta?.total ?? (data as any)?.total ?? items.length; + return (

Remittances

-

Collector cash remittance management

+

Collector cash remittance records

- - + - Reference - Collector - Amount Date + Collector Status - Actions + Total Amount + Confirmed By + Notes - - - No remittances found. - - + {isLoading ? ( + Array.from({ length: 6 }).map((_, i) => ( + {Array.from({ length: 6 }).map((_, j) => ( + + ))} + )) + ) : items.length === 0 ? ( + No remittances yet + ) : ( + items.map((r) => ( + + + {format(new Date(r.createdAt), 'MMM d, yyyy')} + + + {r.collectedBy ? `${r.collectedBy.firstName} ${r.collectedBy.lastName}` : '—'} + + + + {r.status} + + + + ₱{Number(r.totalAmount).toLocaleString()} + + + {r.confirmedBy ? `${r.confirmedBy.firstName} ${r.confirmedBy.lastName}` : '—'} + + + {r.notes ?? '—'} + + + )) + )}