mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +00:00
feat(FE-355,357): Render per-weight-range summary rows
This commit is contained in:
@@ -29,6 +29,7 @@ import Menu from '@/components/menu/Menu';
|
|||||||
import { generateHppPerKandangPDF } from '../export/HppPerkandangExport';
|
import { generateHppPerKandangPDF } from '../export/HppPerkandangExport';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import * as XLSX from 'xlsx';
|
import * as XLSX from 'xlsx';
|
||||||
|
import { Supplier } from '@/types/api/master-data/supplier';
|
||||||
|
|
||||||
interface Totals {
|
interface Totals {
|
||||||
total_hpp_rp: number;
|
total_hpp_rp: number;
|
||||||
@@ -738,7 +739,7 @@ const HppPerKandangTab = () => {
|
|||||||
const renderCustomRow = useCallback(
|
const renderCustomRow = useCallback(
|
||||||
(row: Row<HppPerKandangReport['rows'][0]>) => {
|
(row: Row<HppPerKandangReport['rows'][0]>) => {
|
||||||
if (row.index === data.length - 1) {
|
if (row.index === data.length - 1) {
|
||||||
return (
|
const rows = [
|
||||||
<tr
|
<tr
|
||||||
className='border-b border-l border-r border-b-gray-200 border-l-gray-200 border-r-gray-200'
|
className='border-b border-l border-r border-b-gray-200 border-l-gray-200 border-r-gray-200'
|
||||||
key={'rekapitulasi-row'}
|
key={'rekapitulasi-row'}
|
||||||
@@ -749,13 +750,77 @@ const HppPerKandangTab = () => {
|
|||||||
>
|
>
|
||||||
Rekapitulasi per rentang bobot
|
Rekapitulasi per rentang bobot
|
||||||
</td>
|
</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;
|
return null;
|
||||||
},
|
},
|
||||||
[data]
|
[data, perWeightRangeSummary]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user