import { ExportColumn } from '../export.types';

export const CUSTOMER_COLUMNS: ExportColumn[] = [
  { header: 'No', key: 'no', width: 6 },
  { header: 'Cust Code', key: 'code', width: 14 },
  { header: 'Nama Lengkap', key: 'fullName', width: 26 },
  { header: 'No HP', key: 'phoneNumber', width: 18 },
  { header: 'No KTP', key: 'ktpNumber', width: 22 },
  { header: 'Alamat', key: 'address', width: 32 },
  { header: 'Total Transaksi', key: 'totalTransactions', width: 18 },
  { header: 'Tgl Daftar', key: 'createdAt', width: 16 },
];

export function formatCustomerRows(customers: any[]): Record<string, any>[] {
  return customers.map((c, i) => ({
    no: i + 1,
    code: c.code,
    fullName: c.fullName,
    phoneNumber: c.phoneNumber,
    ktpNumber: c.ktpNumber,
    address: c.address ?? '-',
    totalTransactions: c._count?.transactions ?? 0,
    createdAt: new Date(c.createdAt).toLocaleDateString('id-ID'),
  }));
}