Fix birth date day count off-by-one across signup and settings forms
TLDR: the day dropdown in birth date fields computes days for the month AFTER the one selected, because the 1-indexed month value is passed straight into dayjs’s 0-indexed
.month().
Status: proposed Created: 2026-07-29 Owner: @diegoFranciscoo
Context
In the client registration form (cadastro do cliente), the day dropdown for “Data de nascimento” shows the wrong number of days for most months. Root cause: birth_month is stored 1-indexed (Janeiro=1 … Dezembro=12), matching the MenuItem value={index + 1} used to render month options. This value is passed unmodified into dayjs().month(birthMonthValue), which is 0-indexed (Janeiro=0 … Dezembro=11). The result is that selecting month N always computes the day count of month N+1.
This shifts the day count wrong for 10 of 12 months (Julho→Agosto and Dezembro→Janeiro coincide at 31 days, masking the bug for those two).
The same pattern was copy-pasted into two other forms, each with an additional bug:
TerapeutaPersonalDataForm.tsx(therapist registration): also watches the wrong field name (watch("birth-day")instead ofwatch("birth_month")), so the day options never update when the month changes.FormPersonalInfo.tsx(Meus Dados / account settings): same wrong-field-name bug (watch("birth-day")), but this form uses a different, self-consistent 0-indexed scheme forbirth_day/birth_month(MenuItem value={index}at lines 92 and 120, withdefaultValues computed viaformat("D") - 1/format("M") - 1). The parentsrc/containers/MySettings/MySettings.tsx(lines 77-79) correctly compensates by adding+ 1to both before buildingbirth_datefor the API. Sobirth_monthhere is already 0-indexed and must be passed straight into.month()— no- 1adjustment needed once the field name is fixed. Only the wrongwatchfield name is a bug in this file.
Objectives
- Fix the day dropdown to show the correct number of days for the selected month in all three forms.
- Fix the wrong
watchfield name inTerapeutaPersonalDataForm.tsxandFormPersonalInfo.tsxso day options update when the month changes.
Non-goals
- No redesign of the birth date UI/UX (keep the three separate day/month/year selects).
- No consolidation of the three forms into a single shared component — out of scope for this fix.
- No change to the
birth_yearselect logic. - No change to
FormPersonalInfo.tsx’s 0-indexedbirth_day/birth_monthscheme or toMySettings.tsx’s submit-time+ 1compensation — that pairing is internally correct and out of scope.
Changes
src/components/InputBirthDate/InputBirthDate.tsx— fix.month(birthMonthValue || 0)to.month((birthMonthValue || 1) - 1)(this form’sbirth_monthis 1-indexed).src/containers/Signup/PersonalData/components/TerapeutaPersonalDataForm.tsx— fixwatch("birth-day")towatch("birth_month"); fix the same.month()off-by-one (this form’sbirth_monthis also 1-indexed).src/containers/MySettings/components/FormPersonalInfo.tsx— fixwatch("birth-day")towatch("birth_month")only. Leave.month(birthMonthValue || 0)unchanged, since this form’sbirth_monthis 0-indexed and already matches dayjs’s convention.
How to verify
- Unit test: for each month 1-12, computing days via the fixed logic returns the correct calendar day count (31/30/28/29 as appropriate, including a leap-year case for February).
- Manual: in each of the three forms, select February and confirm the day dropdown shows up to 28 (or 29 in a leap year), not 31; select April and confirm it shows up to 30, not 31.
- Manual: in
TerapeutaPersonalDataForm.tsxandFormPersonalInfo.tsx, confirm changing the month updates the available days (previously it never did).
Documentation
No documentation changes needed.