This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(breadcrumb): add the breadcrumb for the edit appointment view
fix #1854
- Loading branch information
Showing
5 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Appointment from 'model/Appointment' | ||
import { getAppointmentLabel } from '../../../../scheduling/appointments/util/scheduling-appointment.util' | ||
|
||
describe('scheduling appointment util', () => { | ||
describe('getAppointmentLabel', () => { | ||
it('should return the locale string representation of the start time and end time', () => { | ||
const appointment = { | ||
id: '123', | ||
startDateTime: '2020-03-07T18:15:00.000Z', | ||
endDateTime: '2020-03-07T20:15:00.000Z', | ||
} as Appointment | ||
|
||
expect(getAppointmentLabel(appointment)).toEqual( | ||
`${new Date(appointment.startDateTime).toLocaleString()} - ${new Date( | ||
appointment.endDateTime, | ||
).toLocaleString()}`, | ||
) | ||
}) | ||
|
||
it('should return the appointment id when start time is not defined', () => { | ||
const appointment = { | ||
id: '123', | ||
startDateTime: '2020-03-07T18:15:00.000Z', | ||
} as Appointment | ||
|
||
expect(getAppointmentLabel(appointment)).toEqual('123') | ||
}) | ||
|
||
it('should return the appointment id when end time is not defined', () => { | ||
const appointment = { | ||
id: '123', | ||
endDateTime: '2020-03-07T20:15:00.000Z', | ||
} as Appointment | ||
|
||
expect(getAppointmentLabel(appointment)).toEqual('123') | ||
}) | ||
|
||
it('should return the appointment id when start time and end time are not defined', () => { | ||
const appointment = { | ||
id: '123', | ||
} as Appointment | ||
|
||
expect(getAppointmentLabel(appointment)).toEqual('123') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/scheduling/appointments/util/scheduling-appointment.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Appointment from '../../../model/Appointment' | ||
|
||
export function getAppointmentLabel(appointment: Appointment) { | ||
const { id, startDateTime, endDateTime } = appointment | ||
|
||
return startDateTime && endDateTime | ||
? `${new Date(startDateTime).toLocaleString()} - ${new Date(endDateTime).toLocaleString()}` | ||
: id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters