fix: update exit time handling in calculateDay function to ensure proper assignment
This commit is contained in:
@@ -153,14 +153,24 @@ function calculateDay(day) {
|
||||
// const exitTimes = [...day.exitTime]
|
||||
|
||||
// If there's one more entry than exits, it means the user is currently clocked in.
|
||||
if (day.entryTime.length > 0 && day.entryTime.length === day.exitTime.length + 1) {
|
||||
const now = new Date()
|
||||
const hh = String(now.getHours()).padStart(2, '0')
|
||||
const mm = String(now.getMinutes()).padStart(2, '0')
|
||||
const ss = String(now.getSeconds()).padStart(2, '0')
|
||||
// Add the current time as the "exit" for the last entry.
|
||||
day.exitTime.push(`${hh}:${mm}:${ss}`)
|
||||
for (let i = 0; i < day.entryTime.length; i++) {
|
||||
if (!day.exitTime[i] || typeof day.exitTime[i] !== 'string' || day.exitTime[i].trim() === '') {
|
||||
const now = new Date()
|
||||
const hh = String(now.getHours()).padStart(2, '0')
|
||||
const mm = String(now.getMinutes()).padStart(2, '0')
|
||||
const ss = String(now.getSeconds()).padStart(2, '0')
|
||||
|
||||
day.exitTime[i] = `${hh}:${mm}:${ss}`
|
||||
}
|
||||
}
|
||||
// if (day.entryTime.length > 0 && day.entryTime.length === day.exitTime.length + 1) {
|
||||
// const now = new Date()
|
||||
// const hh = String(now.getHours()).padStart(2, '0')
|
||||
// const mm = String(now.getMinutes()).padStart(2, '0')
|
||||
// const ss = String(now.getSeconds()).padStart(2, '0')
|
||||
// // Add the current time as the "exit" for the last entry.
|
||||
// day.exitTime.push(`${hh}:${mm}:${ss}`)
|
||||
// }
|
||||
|
||||
if (day.entryTime.length === 0) {
|
||||
day.workedHours = 0
|
||||
|
||||
Reference in New Issue
Block a user