feat(FE-355,357): Render per-weight-range summary rows

This commit is contained in:
rstubryan
2025-12-20 09:17:31 +07:00
parent c230c8000b
commit c8effe4473
@@ -29,6 +29,7 @@ import Menu from '@/components/menu/Menu';
import { generateHppPerKandangPDF } from '../export/HppPerkandangExport';
import toast from 'react-hot-toast';
import * as XLSX from 'xlsx';
import { Supplier } from '@/types/api/master-data/supplier';
interface Totals {
total_hpp_rp: number;
@@ -738,7 +739,7 @@ const HppPerKandangTab = () => {
const renderCustomRow = useCallback(
(row: Row<HppPerKandangReport['rows'][0]>) => {
if (row.index === data.length - 1) {
return (
const rows = [
<tr
className='border-b border-l border-r border-b-gray-200 border-l-gray-200 border-r-gray-200'
key={'rekapitulasi-row'}
@@ -749,13 +750,77 @@ const HppPerKandangTab = () => {
>
Rekapitulasi per rentang bobot
</td>
</tr>
);
</tr>,
];
if (perWeightRangeSummary.length > 0) {
rows.push(
<tr key={'summary-table-row'}>
<td
colSpan={15}
className='p-0 border-l border-r border-gray-200'
>
<table className='w-full'>
<tbody>
{perWeightRangeSummary.map(
(item: HppPerKandangPerWeightRange, index = 0) => (
<tr
key={`summary-${item.id}`}
className='hover:bg-gray-50 transition-colors border-b border-gray-200'
>
<td className='px-4 py-3 text-xs text-gray-900 whitespace-nowrap border border-gray-200'>
{index + 1}
</td>
<td className='px-4 py-3 text-xs text-gray-900 whitespace-nowrap border border-gray-200'>
ALL
</td>
<td className='px-4 py-3 text-xs text-gray-900 whitespace-nowrap border border-gray-200'>
{item.label}
</td>
<td className='px-4 py-3 text-xs text-gray-900 text-right whitespace-nowrap border border-gray-200'>
{formatNumber(item.avg_weight_kg)}
</td>
<td className='px-4 py-3 text-xs text-gray-900 text-right whitespace-nowrap border border-gray-200'>
{formatNumber(item.remaining_chicken_birds)}
</td>
<td className='px-4 py-3 text-xs text-gray-900 text-right whitespace-nowrap border border-gray-200'>
{formatNumber(item.remaining_chicken_weight_kg)}
</td>
<td className='px-4 py-3 text-xs text-gray-900 whitespace-nowrap border border-gray-200'>
{item.feed_suppliers
?.map((s: Supplier) => s.alias || s.name)
.join(' | ') || '-'}
</td>
<td className='px-4 py-3 text-xs text-gray-900 whitespace-nowrap border border-gray-200'>
{item.doc_suppliers
?.map((s: Supplier) => s.alias || s.name)
.join(' | ') || '-'}
</td>
<td className='px-4 py-3 text-xs text-gray-900 text-right whitespace-nowrap border border-gray-200'>
{formatCurrency(item.average_doc_price_rp)}
</td>
<td className='px-4 py-3 text-xs text-gray-900 text-right whitespace-nowrap border border-gray-200'>
{formatCurrency(item.hpp_rp)}
</td>
<td className='px-4 py-3 text-xs text-gray-900 text-right whitespace-nowrap border border-gray-200'>
{formatCurrency(item.remaining_value_rp)}
</td>
</tr>
)
)}
</tbody>
</table>
</td>
</tr>
);
}
return rows;
}
return null;
},
[data]
[data, perWeightRangeSummary]
);
return (