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 of watch("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 for birth_day/birth_month (MenuItem value={index} at lines 92 and 120, with defaultValues computed via format("D") - 1 / format("M") - 1). The parent src/containers/MySettings/MySettings.tsx (lines 77-79) correctly compensates by adding + 1 to both before building birth_date for the API. So birth_month here is already 0-indexed and must be passed straight into .month() — no - 1 adjustment needed once the field name is fixed. Only the wrong watch field 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 watch field name in TerapeutaPersonalDataForm.tsx and FormPersonalInfo.tsx so 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_year select logic.
  • No change to FormPersonalInfo.tsx’s 0-indexed birth_day/birth_month scheme or to MySettings.tsx’s submit-time + 1 compensation — 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’s birth_month is 1-indexed).
  • src/containers/Signup/PersonalData/components/TerapeutaPersonalDataForm.tsx — fix watch("birth-day") to watch("birth_month"); fix the same .month() off-by-one (this form’s birth_month is also 1-indexed).
  • src/containers/MySettings/components/FormPersonalInfo.tsx — fix watch("birth-day") to watch("birth_month") only. Leave .month(birthMonthValue || 0) unchanged, since this form’s birth_month is 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.tsx and FormPersonalInfo.tsx, confirm changing the month updates the available days (previously it never did).

Documentation

No documentation changes needed.