'use client'; import { useEffect, useRef, useState } from 'react'; import { useTranslations } from '@/core/lib/translations'; import { cn } from '@/core/lib/utils'; import { BIRTH_MONTH_KEYS, birthDayOptions, birthMonthKey, daysInBirthMonth, } from '@/core/lib/birthday'; /** * Single-field birthday picker: one trigger that reads like an ordinary date * field, opening a popover with a month grid and a day grid. * * There is deliberately NO year anywhere. Brainerce stores a month and a day so * the loyalty birthday gift can be sent without keeping anyone's age, which * also rules out `` (it demands a year, and its OS-rendered * popup cannot be restyled) and any date library. * * The popover is hand-rolled for the same reason `checkout/date-picker.tsx` * hand-rolls its calendar: the scaffold ships no popover primitive, and * `src/components/ui/` holds Radix wrappers only with no `react-popover` * dependency to wrap. The trigger markup, the calendar icon and the popover * container are taken from that file on purpose, so the two fields read as * siblings rather than as two different ideas of what a date field looks like. * * Lives in `src/components/shared/` rather than `src/ui/`: canvas scaffolds * wipe `src/ui` and ship no design pack but never touch `src/components/`, and * both the account form and the signup form depend on this. * * The month and the day always leave together. `onChange` emits either a * complete pair or two nulls and never one half, because the API rejects a * month without a day with HTTP 400. Switching to a month that cannot hold * the chosen day clears the birthday rather than moving the day. */ interface BirthdayPickerProps { /** Target for the field's `