Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/apps/calendar/src/lib/components/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { isWeekend } from 'date-fns'
import { MouseEvent, useMemo } from 'react'
import classNames from 'classnames'

import { LoadingSpinner } from '~/libs/ui'

import { LeaveDate } from '../../models'
import { LeaveDate, LeaveStatus } from '../../models'
import {
getDateKey,
getMonthDates,
Expand Down Expand Up @@ -86,9 +87,14 @@ export const Calendar = (props: CalendarProps): JSX.Element => {
}

const dateKey = getDateKey(date)
const isWeekendDate = isWeekend(date)
const status = getStatusForDate(date, leaveDates)
const displayStatus = isWeekendDate && status === LeaveStatus.AVAILABLE
? LeaveStatus.WEEKEND
: status
const isSelected = selectedDates.has(dateKey)
const statusClass = styles[getStatusColor(status)]
const statusClass = styles[getStatusColor(displayStatus)]
const isDisabled = isLoading || isWeekendDate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Disabling the button for weekends (isWeekendDate) might not be the intended behavior if users should be able to select weekends for certain actions. Verify if this logic aligns with the application's requirements.


return (
<button
Expand All @@ -104,7 +110,7 @@ export const Calendar = (props: CalendarProps): JSX.Element => {
)}
data-date-key={dateKey}
onClick={handleDateClick}
disabled={isLoading}
disabled={isDisabled}
>
<span className={styles.dateNumber}>{date.getDate()}</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ const getUserDisplayName = (user: TeamLeaveUser): string => {
.filter(Boolean)
.join(' ')

return fullName || user.handle || user.userId
if (fullName) {
return fullName
}

if (user.status === LeaveStatus.WIPRO_HOLIDAY || user.userId === 'wipro-holiday') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The condition user.userId === 'wipro-holiday' seems to be a hardcoded check for a specific user ID. Consider using a more flexible approach, such as a configuration or a constant, to avoid potential issues if the ID changes in the future.

return user.handle || user.userId
}

return user.userId
}

const compareUsersByName = (userA: TeamLeaveUser, userB: TeamLeaveUser): number => {
Expand Down
Loading