refactor(FE-355): Guard HPP total calculation for empty data

This commit is contained in:
rstubryan
2025-12-18 09:33:13 +07:00
parent 320bc52244
commit 69b4ca455e
@@ -477,7 +477,10 @@ const HppPerKandangTab = () => {
// ===== TABLE COLUMNS DEFINITION ===== // ===== TABLE COLUMNS DEFINITION =====
const totals: Totals = useMemo(() => { const totals: Totals = useMemo(() => {
return { return {
total_hpp_rp: data.reduce((acc, item) => acc + (item.hpp_rp || 0), 0), total_hpp_rp:
data.length > 0
? data.reduce((acc, item) => acc + (item.hpp_rp || 0), 0)
: 0,
total_average_doc_price_rp: total_average_doc_price_rp:
data.length > 0 data.length > 0
? data.reduce( ? data.reduce(