mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
refactor(FE-355,357): Show HPP and average DOC totals in table footer
This commit is contained in:
@@ -27,9 +27,8 @@ import toast from 'react-hot-toast';
|
|||||||
import * as XLSX from 'xlsx';
|
import * as XLSX from 'xlsx';
|
||||||
|
|
||||||
interface Totals {
|
interface Totals {
|
||||||
total_remaining_chicken_birds: number;
|
total_hpp_rp: number;
|
||||||
total_remaining_chicken_weight_kg: number;
|
total_average_doc_price_rp: number;
|
||||||
total_remaining_value_rp: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const HppPerKandangTab = () => {
|
const HppPerKandangTab = () => {
|
||||||
@@ -478,11 +477,14 @@ const HppPerKandangTab = () => {
|
|||||||
// ===== TABLE COLUMNS DEFINITION =====
|
// ===== TABLE COLUMNS DEFINITION =====
|
||||||
const totals: Totals = useMemo(() => {
|
const totals: Totals = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
total_remaining_chicken_birds:
|
total_hpp_rp: data.reduce((acc, item) => acc + (item.hpp_rp || 0), 0),
|
||||||
summary?.total_remaining_chicken_birds || 0,
|
total_average_doc_price_rp:
|
||||||
total_remaining_chicken_weight_kg:
|
data.length > 0
|
||||||
summary?.total_remaining_chicken_weight_kg || 0,
|
? data.reduce(
|
||||||
total_remaining_value_rp: summary?.total_remaining_value_rp || 0,
|
(acc, item) => acc + (item.average_doc_price_rp || 0),
|
||||||
|
0
|
||||||
|
) / data.length
|
||||||
|
: 0,
|
||||||
};
|
};
|
||||||
}, [summary]);
|
}, [summary]);
|
||||||
|
|
||||||
@@ -643,7 +645,9 @@ const HppPerKandangTab = () => {
|
|||||||
return <div className='text-right'>{formatCurrency(value)}</div>;
|
return <div className='text-right'>{formatCurrency(value)}</div>;
|
||||||
},
|
},
|
||||||
footer: () => (
|
footer: () => (
|
||||||
<div className='text-right font-semibold text-gray-900'>-</div>
|
<div className='text-right font-semibold text-gray-900'>
|
||||||
|
{formatCurrency(totals?.total_average_doc_price_rp || 0)}
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -669,7 +673,9 @@ const HppPerKandangTab = () => {
|
|||||||
return <div className='text-right'>{formatCurrency(value)}</div>;
|
return <div className='text-right'>{formatCurrency(value)}</div>;
|
||||||
},
|
},
|
||||||
footer: () => (
|
footer: () => (
|
||||||
<div className='text-right font-semibold text-gray-900'>-</div>
|
<div className='text-right font-semibold text-gray-900'>
|
||||||
|
{formatCurrency(totals?.total_hpp_rp || 0)}
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user