Skip to content

Commit

Permalink
no undefined or double negatives
Browse files Browse the repository at this point in the history
  • Loading branch information
Joosakur committed Nov 12, 2024
1 parent 40346b1 commit 221166e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export type AttendanceStatuses = Record<
>

export type ChildAttendanceStatus = ChildAttendanceStatusResponse & {
noServiceToday?: boolean
hasOperationalDay: boolean
}

export function childAttendanceStatus(
child: AttendanceChild,
attendanceStatuses: Record<UUID, ChildAttendanceStatusResponse | undefined>
): ChildAttendanceStatus {
const status = attendanceStatuses[child.id]
if (status) return status
if (status) return { ...status, hasOperationalDay: true }

if (
child.scheduleType === 'TERM_BREAK' ||
Expand All @@ -55,12 +55,13 @@ export function childAttendanceStatus(
const defaultChildAttendanceStatus: ChildAttendanceStatus = {
status: 'COMING',
attendances: [],
absences: []
absences: [],
hasOperationalDay: true
}

const childAttendanceStatusNoService: ChildAttendanceStatus = {
status: 'ABSENT',
attendances: [],
absences: [],
noServiceToday: true
hasOperationalDay: false
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,7 @@ export default React.memo(function AttendanceChildPage({
</Zindex>

<FlexColumn paddingHorizontal="s">
{childAttendance.noServiceToday ? (
<>
<Center data-qa="term-break">
{i18n.attendances.termBreak}
</Center>
<Gap size="XXL" />
</>
) : (
{childAttendance.hasOperationalDay ? (
<>
<AttendanceDailyServiceTimes
dailyServiceTimes={child.dailyServiceTimes}
Expand All @@ -230,6 +223,13 @@ export default React.memo(function AttendanceChildPage({
placementType={child.placementType}
/>
</>
) : (
<>
<Center data-qa="term-break">
{i18n.attendances.termBreak}
</Center>
<Gap size="XXL" />
</>
)}
<Gap size="xs" />
{childAttendance.status === 'COMING' && (
Expand All @@ -246,7 +246,7 @@ export default React.memo(function AttendanceChildPage({
<AttendanceChildDeparted unitId={unitId} child={child} />
)}
{childAttendance.status === 'ABSENT' &&
!childAttendance.noServiceToday && (
childAttendance.hasOperationalDay && (
<AttendanceChildAbsent
childId={childId}
unitId={unitId}
Expand Down

0 comments on commit 221166e

Please sign in to comment.