Skip to content

Optional: replace react-datepicker in the admin reports with a shared date picker #2289

Open

Description

@trillium

Trillium Firstmate 🤖

Overview

The admin reports page uses a second date library, react-datepicker, with its own CSS. This optional follow-up replaces it with a shared day-level date picker built on the same popover pattern as the month/year picker, so the app has one date input style.

Dependencies

Action Items

Run yarn commands from client/, and commit client/package.json and client/yarn.lock together.

  • Read how the two pickers are used in client/src/components/admin/reports/index.jsx (lines ~3, 171, 184): which dates they set, any limits, and the date format shown.
  • Create client/src/components/ui/date-picker.tsx: an input-style button that opens a popover with a month calendar (previous/next month, day grid, today highlight, selected day). Reuse the popover and styling of MonthYearPicker. Support value, onChange, minDate, maxDate, disabled, error. Use date-fns for date math and formatting.
  • Keyboard: arrow keys move by day and week, Page Up/Down by month, Home/End to start/end of week, Enter selects, Escape closes.
  • Replace both DatePicker uses in the reports page, keep the same data sent to the request, and delete client/src/common/datepicker/index.scss.
  • Remove react-datepicker from client/package.json.
  • Colocated tests (open/close, select a day, min/max, keyboard) and a catalogue entry.

Acceptance Criteria

  • The component lives in client/src/components/ui/ as a .tsx file, with typed props that pass yarn typecheck (strict mode).
  • Styling uses Tailwind classes only. Variants (if any) are declared with cva, and className is merged with cn() so callers can override.
  • The component does not import anything from @mui/* or @emotion/*.
  • A test file next to the component (for example button.test.tsx) covers: it renders, each variant/size, the disabled and error states where they apply, and keyboard use where it applies (Tab, Enter/Space, Escape, arrow keys). yarn test passes.
  • The reports page behaves the same: same default dates, same requests, same format.
  • git grep react-datepicker finds nothing in client/.
  • Before/after screenshots of the reports page, with the picker open.

Resources/Instructions

  • Current uses: client/src/components/admin/reports/index.jsx, styles in client/src/common/datepicker/index.scss.
  • Date handling in the app today mixes moment and date-fns; this ticket only uses date-fns for new code.

Additional Notes

  • Optional: the main goal (no MUI) does not need this. It is worth doing for one date style and about 96 kB less JavaScript (from an earlier measurement), but it can be skipped or postponed.
  • Decision needed: build vs adopt. Proposed default: build on the existing popover pattern. A small calendar library such as react-day-picker is an acceptable alternative; if chosen, wrap it in the same ui/date-picker.tsx API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature: Design systemmilestone: missingrole: Front Endsize: 3pt

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions