From a0e63ea2d461400a3e59a3d8f1e9b0dc98cb88d5 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Sat, 20 Dec 2025 09:37:42 +0700 Subject: [PATCH] refactor(FE-355): Use flexRender and prepend default row in table --- .../report/sale/tab/HppPerKandangTab.tsx | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/pages/report/sale/tab/HppPerKandangTab.tsx b/src/components/pages/report/sale/tab/HppPerKandangTab.tsx index ff35eb45..5248521f 100644 --- a/src/components/pages/report/sale/tab/HppPerKandangTab.tsx +++ b/src/components/pages/report/sale/tab/HppPerKandangTab.tsx @@ -13,7 +13,7 @@ import { LocationApi } from '@/services/api/master-data'; import { KandangApi } from '@/services/api/master-data'; import { SaleReportApi } from '@/services/api/report/marketing-sale'; import Table from '@/components/Table'; -import { ColumnDef, Row } from '@tanstack/react-table'; +import { ColumnDef, Row, flexRender } from '@tanstack/react-table'; import { formatCurrency, formatNumber } from '@/lib/helper'; import { HppPerKandangReport, @@ -739,7 +739,23 @@ const HppPerKandangTab = () => { const renderCustomRow = useCallback( (row: Row) => { if (row.index === data.length - 1) { - const rows = [ + const defaultRow = ( + + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + ); + + const customRows = [ { ]; if (perWeightRangeSummary.length > 0) { - rows.push( + customRows.push( { ); } - return rows; + return [defaultRow, ...customRows]; } return null;