mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 14:55:44 +00:00
46 lines
994 B
TypeScript
46 lines
994 B
TypeScript
'use client';
|
|
|
|
import { View, StyleSheet } from '@react-pdf/renderer';
|
|
import { PdfThead, PdfColumn } from './PdfThead';
|
|
import { PdfTbody, PdfTbodyCell } from './PdfTbody';
|
|
import { PdfTfoot, PdfTfootCell } from './PdfTfoot';
|
|
|
|
const styles = StyleSheet.create({
|
|
table: {
|
|
borderWidth: 1,
|
|
borderColor: '#000000',
|
|
marginBottom: 15,
|
|
},
|
|
});
|
|
|
|
interface PdfTableProps {
|
|
columns: PdfColumn[];
|
|
data: PdfTbodyCell[][];
|
|
footer?: PdfTfootCell[];
|
|
footerLabel?: string;
|
|
firstRow?: {
|
|
valueKey: string;
|
|
value: number;
|
|
align?: 'right';
|
|
color?: string;
|
|
};
|
|
}
|
|
|
|
export const PdfTable = ({
|
|
columns,
|
|
data,
|
|
footer,
|
|
footerLabel = 'Total',
|
|
firstRow,
|
|
}: PdfTableProps) => {
|
|
return (
|
|
<View style={styles.table}>
|
|
<PdfThead columns={columns} />
|
|
<PdfTbody columns={columns} rows={data} firstRow={firstRow} />
|
|
{footer && footer.length > 0 && (
|
|
<PdfTfoot columns={columns} cells={footer} label={footerLabel} />
|
|
)}
|
|
</View>
|
|
);
|
|
};
|