chore: add total hpp price per kg footer

This commit is contained in:
ValdiANS
2026-01-13 10:21:22 +07:00
parent 021df11600
commit 3b666a924f
@@ -60,9 +60,10 @@ const DailyMarketingsTable = ({
footer: 'Total', footer: 'Total',
}, },
{ {
accessorKey: 'do_date', accessorKey: 'realization_date',
header: 'Tanggal DO', header: 'Tanggal Realisasi',
cell: (props) => formatDate(props.row.original.do_date, 'DD-MMM-YYYY'), cell: (props) =>
formatDate(props.row.original.realization_date, 'DD-MMM-YYYY'),
}, },
{ {
accessorKey: 'aging_days', accessorKey: 'aging_days',
@@ -106,10 +107,10 @@ const DailyMarketingsTable = ({
cell: (props) => formatNumber(props.row.original.qty), cell: (props) => formatNumber(props.row.original.qty),
footer: () => { footer: () => {
const totalQty = isResponseSuccess(dailyMarketings) const totalQty = isResponseSuccess(dailyMarketings)
? dailyMarketings.data.summary.total_qty ? dailyMarketings?.total?.total_qty
: 0; : 0;
return formatNumber(totalQty); return totalQty ? formatNumber(totalQty) : '-';
}, },
}, },
{ {
@@ -123,10 +124,10 @@ const DailyMarketingsTable = ({
cell: (props) => formatNumber(props.row.original.total_weight_kg), cell: (props) => formatNumber(props.row.original.total_weight_kg),
footer: () => { footer: () => {
const totalWeightKg = isResponseSuccess(dailyMarketings) const totalWeightKg = isResponseSuccess(dailyMarketings)
? dailyMarketings.data.summary.total_weight_kg ? dailyMarketings?.total?.total_weight_kg
: 0; : 0;
return formatNumber(totalWeightKg); return totalWeightKg ? formatNumber(totalWeightKg) : '-';
}, },
}, },
{ {
@@ -138,6 +139,13 @@ const DailyMarketingsTable = ({
accessorKey: 'hpp_price_per_kg', accessorKey: 'hpp_price_per_kg',
header: 'HPP (Rp)', header: 'HPP (Rp)',
cell: (props) => formatCurrency(props.row.original.hpp_price_per_kg), cell: (props) => formatCurrency(props.row.original.hpp_price_per_kg),
footer: () => {
const totalHppPricePerKg = isResponseSuccess(dailyMarketings)
? dailyMarketings?.total?.total_hpp_price_per_kg
: 0;
return totalHppPricePerKg ? formatCurrency(totalHppPricePerKg) : '-';
},
}, },
{ {
accessorKey: 'sales_amount', accessorKey: 'sales_amount',
@@ -145,10 +153,10 @@ const DailyMarketingsTable = ({
cell: (props) => formatCurrency(props.row.original.sales_amount), cell: (props) => formatCurrency(props.row.original.sales_amount),
footer: () => { footer: () => {
const totalSalesAmount = isResponseSuccess(dailyMarketings) const totalSalesAmount = isResponseSuccess(dailyMarketings)
? dailyMarketings.data.summary.total_sales_amount ? dailyMarketings?.total?.total_sales_amount
: 0; : 0;
return formatCurrency(totalSalesAmount); return totalSalesAmount ? formatCurrency(totalSalesAmount) : '-';
}, },
}, },
]; ];
@@ -167,7 +175,7 @@ const DailyMarketingsTable = ({
if (!open) { if (!open) {
setOpen( setOpen(
isResponseSuccess(dailyMarketings) isResponseSuccess(dailyMarketings)
? dailyMarketings.data.rows.length > 0 ? dailyMarketings.data.length > 0
: false : false
); );
} }
@@ -215,9 +223,7 @@ const DailyMarketingsTable = ({
<Table<DailyMarketingRow> <Table<DailyMarketingRow>
data={ data={
isResponseSuccess(dailyMarketings) isResponseSuccess(dailyMarketings) ? dailyMarketings?.data : []
? dailyMarketings?.data.rows
: []
} }
columns={dailyMarketingColumns} columns={dailyMarketingColumns}
pageSize={pageSize} pageSize={pageSize}
@@ -242,7 +248,7 @@ const DailyMarketingsTable = ({
containerClassName: cn({ containerClassName: cn({
'w-full mb-20': 'w-full mb-20':
isResponseSuccess(dailyMarketings) && isResponseSuccess(dailyMarketings) &&
dailyMarketings?.data?.rows.length === 0, dailyMarketings?.data?.length === 0,
}), }),
}} }}
/> />