refactor(FE-355): Render weight-range summaries as table rows

This commit is contained in:
rstubryan
2025-12-20 09:47:50 +07:00
parent a0e63ea2d4
commit eb8a1567c6
@@ -747,7 +747,7 @@ const HppPerKandangTab = () => {
{row.getVisibleCells().map((cell) => ( {row.getVisibleCells().map((cell) => (
<td <td
key={cell.id} key={cell.id}
className='px-4 py-3 text-xs text-gray-900 whitespace-nowrap border border-gray-200' className='px-4 py-3 text-xs text-gray-900 whitespace-nowrap border-gray-200'
> >
{flexRender(cell.column.columnDef.cell, cell.getContext())} {flexRender(cell.column.columnDef.cell, cell.getContext())}
</td> </td>
@@ -770,19 +770,12 @@ const HppPerKandangTab = () => {
]; ];
if (perWeightRangeSummary.length > 0) { if (perWeightRangeSummary.length > 0) {
perWeightRangeSummary.forEach(
(item: HppPerKandangPerWeightRange, index = 0) => {
customRows.push( customRows.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 <tr
key={`summary-${item.id}`} key={`summary-${item.id}`}
className='hover:bg-gray-50 transition-colors border-b border-gray-200 [&_td]:px-4 [&_td]:py-3 [&_td]:text-xs [&_td]:text-gray-900 [&_td]:whitespace-nowrap [&_td]:border [&_td]:border-gray-200' className='hover:bg-gray-50 transition-colors border-b border-l border-r border-b-gray-200 border-l-gray-200 border-r-gray-200 [&_td]:px-4 [&_td]:py-3 [&_td]:text-xs [&_td]:text-gray-900 [&_td]:whitespace-nowrap'
> >
<td className=''>{index + 1}</td> <td className=''>{index + 1}</td>
<td className=''>ALL</td> <td className=''>ALL</td>
@@ -800,31 +793,26 @@ const HppPerKandangTab = () => {
<td className='text-right'>-</td> <td className='text-right'>-</td>
<td className=''> <td className=''>
{item.feed_suppliers {item.feed_suppliers
?.map((s: Supplier) => s.alias || s.name) ?.map((s) => s.alias || s.name)
.join(' | ') || '-'} .join(' | ') || '-'}
</td> </td>
<td className=''> <td className=''>
{item.doc_suppliers {item.doc_suppliers
?.map((s: Supplier) => s.alias || s.name) ?.map((s) => s.alias || s.name)
.join(' | ') || '-'} .join(' | ') || '-'}
</td> </td>
<td className='text-right'> <td className='text-right'>
{formatCurrency(item.average_doc_price_rp)} {formatCurrency(item.average_doc_price_rp)}
</td> </td>
<td className='text-right'> <td className='text-right'>-</td>
{formatCurrency(item.hpp_rp)} <td className='text-right'>{formatCurrency(item.hpp_rp)}</td>
</td>
<td className='text-right'>-</td> <td className='text-right'>-</td>
<td className='text-right'> <td className='text-right'>
{formatCurrency(item.remaining_value_rp)} {formatCurrency(item.remaining_value_rp)}
</td> </td>
</tr> </tr>
) );
)} }
</tbody>
</table>
</td>
</tr>
); );
} }