'use client'; import { Text, View, StyleSheet } from '@react-pdf/renderer'; export interface PdfColumn { key: string; header: string; flex: number; align?: 'left' | 'center' | 'right'; } export interface PdfTfootCell { key: string; value: string | number; align?: 'left' | 'center' | 'right'; flex?: number; color?: string; } const styles = StyleSheet.create({ tableRow: { flexDirection: 'row', }, summaryRow: { backgroundColor: '#F0F0F0', fontWeight: 'bold', }, tableCell: { flex: 1, borderRightWidth: 1, borderRightColor: '#000000', borderRightStyle: 'solid', padding: 4, fontSize: 7, textAlign: 'left', }, tableCellLast: { flex: 1, padding: 4, fontSize: 7, borderRightWidth: 0, }, tableCellRight: { flex: 1, borderRightWidth: 1, borderRightColor: '#000000', borderRightStyle: 'solid', padding: 4, fontSize: 7, textAlign: 'right', }, tableCellCenter: { flex: 1, borderRightWidth: 1, borderRightColor: '#000000', borderRightStyle: 'solid', padding: 4, fontSize: 7, textAlign: 'center', }, tableCellNo: { flex: 0.5, borderRightWidth: 1, borderRightColor: '#000000', borderRightStyle: 'solid', padding: 4, fontSize: 7, textAlign: 'center', }, }); interface PdfTfootProps { columns: PdfColumn[]; cells: PdfTfootCell[]; label?: string; } export const PdfTfoot = ({ columns, cells, label = 'Total' }: PdfTfootProps) => { return ( {columns.map((column, index) => { const isLastColumn = index === columns.length - 1; const cellData = cells.find((c) => c.key === column.key); const cellStyle = column.key === 'no' ? [styles.tableCellNo, { flex: column.flex }] : cellData?.align === 'right' ? [ styles.tableCellRight, { flex: column.flex, color: cellData?.color || 'black', }, ] : cellData?.align === 'center' ? [ styles.tableCellCenter, { flex: column.flex, color: cellData?.color || 'black', }, ] : isLastColumn ? [styles.tableCellLast, { flex: column.flex }] : [ styles.tableCell, { flex: column.flex, color: cellData?.color || 'black', }, ]; return ( {column.key === 'no' ? label : cellData?.value || ''} ); })} ); };