feat(site): replace account date inputs with shadcn calendar - #1035
Open
Orlando275 wants to merge 1 commit into
Open
feat(site): replace account date inputs with shadcn calendar#1035Orlando275 wants to merge 1 commit into
Orlando275 wants to merge 1 commit into
Conversation
The two date fields on the management zone page used native date inputs. They now open a shadcn calendar inside a popover, wired through react-hook-form's controller since the trigger is a button rather than an input. Dates are converted at both ends of the picker. The date columns round-trip at UTC midnight while react-day-picker builds its dates at local midnight, so without the conversion the stored day would shift for users east of UTC. The month dropdowns declare an explicit range because react-day-picker otherwise caps navigation at the end of the current year, which would leave future rotation dates unreachable. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the /account/management-zones/[zone] form to replace the two native date inputs (“Rotation year” and “NPK last used”) with a shadcn-style calendar popover, addressing the UI request in #748 while handling UTC-midnight date round-tripping safely.
Changes:
- Replaced native
<input type="date">fields with Radix Popover + shadcn Calendar, wired viareact-hook-formController. - Added timezone-safe conversion helpers to prevent day shifting when converting between DB
datevalues (UTC midnight) and calendar selections (local midnight). - Added unit tests to pin the submitted date value to UTC midnight and verify trigger display/disabled behavior.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| bun.lock | Adds lockfile entries for @radix-ui/react-popover and react-day-picker (plus a minor brace-expansion bump). |
| apps/site/package.json | Adds runtime deps needed for the popover calendar UI (@radix-ui/react-popover, react-day-picker). |
| apps/site/src/components/ui/popover.tsx | Introduces shadcn-style Popover wrapper used by the date fields. |
| apps/site/src/components/ui/calendar.tsx | Adds shadcn-style Calendar component (Tailwind v4-compatible sizing classes) backed by react-day-picker. |
| apps/site/src/app/(authenticated)/(no-sidebar)/account/(with-shell)/management-zones/[zone]/management-zone-form.tsx | Replaces the two date inputs with calendar popover triggers and UTC/local conversion helpers. |
| apps/site/src/app/(authenticated)/(no-sidebar)/account/(with-shell)/management-zones/[zone]/management-zone-form.test.tsx | Adds tests covering trigger display, UTC-midnight submission, and read-only disabling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+123
to
+124
| // A `<label for>` does not name a button, so the trigger | ||
| // carries the label and the current value itself. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #748
The two date fields on
/account/management-zones/[zone]—Rotation yearandNPK last used— used native<input type="date">. They now open the shadcn calendar inside a popover. Since the trigger is a button rather than an input, they are wired through react-hook-form'sControllerinstead ofregister.These were the only native date pickers under
/account; the other two account route groups (/account/agreementand/account/reset-password) have no date UI.Notes for review
Timezone. The
datecolumns round-trip at UTC midnight, while react-day-picker builds its dates at local midnight. Without converting on both ends, the stored day shifts by one for users east of UTC.toCalendarDate/fromCalendarDatehandle this, and a test pins the submitted value to2026-07-15T00:00:00.000Z.Year range. With
captionLayout="dropdown", react-day-picker caps navigation at the end of the current year by default, which would make future rotation dates unreachable — a regression against the native input. The range is declared explicitly as 50 years back and 10 forward. Happy to change the window if you'd prefer different bounds; it's two constants.Tailwind v4. The shadcn CLI serves the Tailwind v3 flavour of
calendar.tsx, becausecomponents.jsondeclares atailwind.config.ts. Itsh-[--cell-size]classes compile to invalid CSS under v4 (height: --cell-size, which browsers drop), which would have left the calendar misaligned. They were converted to the v4h-(--cell-size)syntax and verified against the compiled production CSS. Note thattype-check,lint,testandbuildall pass either way, since none of them evaluate CSS.Accessibility. A
<label for>does not name a<button>, so each trigger carries anaria-labelcombining its label and current value.calendar.tsxandpopover.tsxare shadcn output kept as generated, apart from the Tailwind fix and the copyright header. They carry no stories or tests, matching the other 22 components insrc/components/ui/.Checklist
🤖 Generated with Claude Code