From f8be2ce0bea31d68dc3a39c8c8351cb3281695fd Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Thu, 25 Jan 2024 14:57:13 +0700 Subject: [PATCH 1/2] tambah fitur kalkulator / total benefit --- .../pages/CustomerService/FinalLog/Detail.tsx | 110 +++++++++++++++++- 1 file changed, 108 insertions(+), 2 deletions(-) diff --git a/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx b/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx index 3dd6be43..722c70e0 100644 --- a/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx +++ b/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx @@ -116,6 +116,22 @@ export default function Detail() { // Handle Edit Detail Benefit const [openDialogEditBenefit, setDialogEditBenefit] = useState(false) const [BenefitConfigurationData, setBenefitConfigurationData] = useState(); + + // Buat total data + const totalAmountIncurred = (requestLog?.benefit_data || []).reduce((accumulator, item) => { + return accumulator + (item.amount_incurred || 0); + }, 0); + const totalAmountApprove = (requestLog?.benefit_data || []).reduce((accumulator, item) => { + return accumulator + (item.amount_approved || 0); + }, 0); + const totalAmountNotApprove = (requestLog?.benefit_data || []).reduce((accumulator, item) => { + return accumulator + (item.amount_not_approved || 0); + }, 0); + const totalExcessPaid = (requestLog?.benefit_data || []).reduce((accumulator, item) => { + return accumulator + (item.excess_paid || 0); + }, 0); + + return ( @@ -402,8 +418,98 @@ export default function Detail() { ))} - - +
+
+ {requestLog?.benefit_data && requestLog.benefit_data.length > 0 ? ( + + + + + + + Total Benefit + + + + + + + + + + {/* Amount Incurred */} + + + + + Amount Incurred + + + + + {fNumber(totalAmountIncurred)} + + + + + + {/* Amount Approved */} + + + + + Amount Approved + + + + + {fNumber(totalAmountApprove)} + + + + + + {/* Amount Not Approved */} + + + + + Amount Not Approved + + + + + {fNumber(totalAmountNotApprove)} + + + + + + {/* Excess Paid* */} + + + + + Excess Paid + + + + + {fNumber(totalExcessPaid)} + + + + + + + + + + + ) + : ( + null + )} {/* PR Buat pindahin ke componen */} From 908a8aff0a17637ddf62ebc4a5d35848aaa76efa Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Thu, 25 Jan 2024 15:52:17 +0700 Subject: [PATCH 2/2] update key --- .../dashboard/src/pages/CustomerService/FinalLog/Detail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx b/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx index 722c70e0..a3f32953 100644 --- a/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx +++ b/frontend/dashboard/src/pages/CustomerService/FinalLog/Detail.tsx @@ -421,7 +421,7 @@ export default function Detail() {

{requestLog?.benefit_data && requestLog.benefit_data.length > 0 ? ( - +