From 8cc720288166a9bfe4892549510f869d83cc4127 Mon Sep 17 00:00:00 2001
From: Rosyid Haryadi <rosyid_haryadi@protonmail.com>
Date: Sun, 1 Oct 2023 14:53:12 +0700
Subject: upd weekend indication in details

---
 src/Result.jsx | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

(limited to 'src/Result.jsx')

diff --git a/src/Result.jsx b/src/Result.jsx
index 3ba9a4e..e79ba7f 100644
--- a/src/Result.jsx
+++ b/src/Result.jsx
@@ -30,7 +30,7 @@ function Result({listEntry, baseSalary}) {
                 return (
                     <div key={entry.id}>
                         <Typography>
-                            {entry.date.format('DD MMMM YYYY')}: Rp<NumericFormat displayType="text" decimalScale={0} thousandSeparator={true} value={calculatePerDay(entry, baseSalary)} />
+                            {entry.date.format('DD MMMM YYYY')}{weekendDay(entry.date) ? ` (${weekendDay(entry.date)})` : ''}: Rp<NumericFormat displayType="text" decimalScale={0} thousandSeparator={true} value={calculatePerDay(entry, baseSalary)} />
                         </Typography>
                     </div>
                 )
@@ -56,6 +56,15 @@ function segmentTime(duration, segments) {
     return segmentedHours;
 }
 
+function weekendDay(date) {
+    if (date.day() === 0) {
+        return 'Minggu';
+    } else if (date.day() === 6) {
+        return 'Sabtu';
+    }
+    return '';
+}
+
 function calculatePerDay(entry, baseSalary) {
     const hourlyPay = baseSalary / 173;
     const overtimeDuration = entry.finish.diff(entry.start, 'hour', true);
@@ -74,10 +83,8 @@ function calculatePerDay(entry, baseSalary) {
         ]
     }
 
-    const isWeekend = entry.date.day() === 0 || entry.date.day() === 6; // 0: Minggu, 6: Sabtu
-
     const segmentedDuration = segmentTime(overtimeDuration, [1]);
-    const usedMap = isWeekend ? multiplierMap.holidays : multiplierMap.workDays;
+    const usedMap = weekendDay(entry.date) ? multiplierMap.holidays : multiplierMap.workDays;
     for (let i = 0; i < segmentedDuration.length; i++) {
         multiplier += segmentedDuration[i] * usedMap[i];
     }
-- 
cgit v1.2.3-70-g09d2

