Skip to content

feat: date range picker in Visit Registration replaces two date pickers#1603

Open
shivoomiess wants to merge 7 commits into
developfrom
SWAP-5412-daterange-visitform
Open

feat: date range picker in Visit Registration replaces two date pickers#1603
shivoomiess wants to merge 7 commits into
developfrom
SWAP-5412-daterange-visitform

Conversation

@shivoomiess

@shivoomiess shivoomiess commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Description

Replaces the two separate "Visit start" and "Visit end" date pickers in the Visit Registration form with a single date-range picker. Selecting a range now populates both startsAt and endsAt from one calendar UI.

Screenshot 2026-06-24 at 13 27 23

Motivation and Context

Registering a visit previously required interacting with two independent MUI date pickers, which was clunky and made it easy to pick an end date before the start date. A single range picker is more intuitive, keeps start/end selection in one place, and visually communicates the selected span. It also drops the MUI @mui/x-date-pickers / LocalizationProvider boilerplate that only existed to work around Cypress/Material-UI datepicker testing issues.

Changes

  1. Added a new reusable FormikUIDayRangePicker.tsx component built on react-day-picker, rendering the calendar inside an MUI Popover (so it isn't clipped by the modal) with a read-only text field, a calendar icon button, and a "Done" button. It supports minDate, custom Luxon display format, required/disabled/error states, and themed range styling.
  2. Rewrote QuestionaryComponentVisitBasis.tsx to use the new DayRangePicker instead of the two Field/DatePicker instances wrapped in LocalizationProvider.
  3. Added a toDateTime helper to normalize startsAt/endsAt, which arrive as Luxon DateTimes once edited but as ISO strings when a registration is loaded from the backend.
  4. Wired Formik touched/errors (via getIn) into the range picker so start/end validation errors surface on the single field.
  5. Removed the now-unused useTheme and desktopModeMediaQuery Cypress workaround.

How Has This Been Tested?

Visually, we can see that the functionality works as intended. Since there are no changes on the backend and the frontend uses the same flow to send / receive data, we confirm the changes have been tested sufficiently.

Fixes Jira Issue

https://jira.ess.eu//browse/SWAP-5412

Depends On

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@shivoomiess shivoomiess requested a review from a team as a code owner June 24, 2026 11:29
@shivoomiess shivoomiess requested review from TCMeldrum, jekabs-karklins and yoganandaness and removed request for a team and TCMeldrum June 24, 2026 11:29
Comment thread apps/frontend/src/components/common/FormikUIDayRangePicker.tsx Outdated
Comment thread apps/frontend/src/components/common/FormikUIDayRangePicker.tsx
Comment thread apps/frontend/src/components/common/FormikUIDayRangePicker.tsx

@jekabs-karklins jekabs-karklins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@shivoomiess shivoomiess enabled auto-merge (squash) June 30, 2026 08:04
: undefined;

return (
<div style={{ display: 'flex' }}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use MUI box instead of div

<Box sx={{ display: 'flex' }}>


return (
<div style={{ display: 'flex' }}>
<div style={{ flex: 1 }}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the separate “Visit start” and “Visit end” date pickers in the Visit Registration flow with a single date-range picker UI, aiming to make selecting a valid start/end range more intuitive and avoid MUI date-picker/Cypress friction.

Changes:

  • Introduces a new FormikUIDayRangePicker component built on react-day-picker rendered in an MUI Popover.
  • Updates QuestionaryComponentVisitBasis to use the new range picker and map the selected range to startsAt/endsAt.
  • Adds a toDateTime helper to normalize backend-loaded ISO strings into Luxon DateTime.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
apps/frontend/src/components/questionary/questionaryComponents/VisitBasis/QuestionaryComponentVisitBasis.tsx Switches Visit Registration date inputs to a single range picker and adds normalization for loaded values.
apps/frontend/src/components/common/FormikUIDayRangePicker.tsx Adds a reusable day range picker component using react-day-picker inside an MUI Popover.

Comment on lines +73 to +78
onChange={({ from, to }: DayRange) => {
dispatch({
type: 'ITEM_WITH_QUESTIONARY_MODIFIED',
itemWithQuestionary: { startsAt: from, endsAt: to },
});
}}
Comment on lines +30 to +32
if (typeof value === 'string') {
return DateTime.fromISO(value);
}
Comment on lines +102 to +104
const disabledDays: Matcher | undefined = minDate
? { before: minDate.toJSDate() }
: undefined;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants