import React from 'react'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Card, CardContent } from "@/components/ui/card"; import { useSupabaseEmployeeData } from "@/hooks/useSupabaseEmployeeData"; export const OutstandingReportDashboard = () => { const { employees, getEmployeeSummary } = useSupabaseEmployeeData(); const employeeSummaries = employees.map(employee => { const summary = getEmployeeSummary(employee.id); return { ...employee, ...summary }; }); const formatCurrency = (amount: number) => { return new Intl.NumberFormat('en-IN', { style: 'currency', currency: 'INR' }).format(amount); }; const formatDate = (date: string) => { return new Date(date).toLocaleDateString('en-IN'); }; // Calculate totals const totalCollection = employeeSummaries.reduce((sum, emp) => sum + emp.totalCollection, 0); const totalDeposit = employeeSummaries.reduce((sum, emp) => sum + emp.totalDeposit, 0); const totalDifference = totalCollection - totalDeposit; return (
Outstanding Report (All Locations)
{/* Summary Cards */}

Total Collection (MM)

(All Locations)

{formatCurrency(totalCollection)}

Total Deposit Amount

(All Locations)

{formatCurrency(totalDeposit)}

=

Difference Amount

(All Locations)

{formatCurrency(totalDifference)}

{/* Data Table */}
Location Emp. ID Emp. Name Collections (MM) Date Difference {employeeSummaries.map((employee) => ( BGRoad, Karnataka {employee.emp_id.replace('EMP', '')} {employee.name} {employee.totalCollection.toLocaleString()} {employee.lastTransactionDate ? formatDate(employee.lastTransactionDate) : '26 Mar 2025'} 0 ? 'text-red-600' : 'text-green-600'}`}> {employee.outstandingAmount > 0 ? employee.outstandingAmount.toLocaleString() : `(${Math.abs(employee.outstandingAmount).toLocaleString()})`} ))}
{/* Pagination */}
Show Rows
...
{employeeSummaries.length === 0 && (
No employee data available
Use the "Insert Employee Data" button to add records
)}
); };