diff options
author | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2023-10-01 14:53:12 +0700 |
---|---|---|
committer | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2023-10-01 14:53:12 +0700 |
commit | 8cc720288166a9bfe4892549510f869d83cc4127 (patch) | |
tree | fd44a1c45291a2ea0ea04501c036b8c1c6c4a3c8 /src | |
parent | 1994eefbb9f516e4cc616a347bb2a51d619c457a (diff) |
upd weekend indication in details
Diffstat (limited to 'src')
-rw-r--r-- | src/Result.jsx | 15 |
1 files changed, 11 insertions, 4 deletions
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]; } |