From da423412720bb4b2e5c6dbbc34d607c421c16645 Mon Sep 17 00:00:00 2001 From: Moon <195389365+Moon-dg@users.noreply.github.com> Date: Mon, 12 Oct 2026 15:16:03 -0500 Subject: [PATCH 1/4] fix: Restore DOB date picker, gender select dropdown, and color tokens --- frontend/src/pages/auth/Signup.jsx | 45 ++++++++++++++++--------- frontend/src/pages/auth/Signup.test.jsx | 34 ++++++++++--------- frontend/tailwind.config.js | 15 ++++++++- 3 files changed, 61 insertions(+), 33 deletions(-) diff --git a/frontend/src/pages/auth/Signup.jsx b/frontend/src/pages/auth/Signup.jsx index 5140175..7362541 100644 --- a/frontend/src/pages/auth/Signup.jsx +++ b/frontend/src/pages/auth/Signup.jsx @@ -18,7 +18,7 @@ const Signup = ({ onAuthSuccess = () => {} }) => { const [form, setForm] = useState({ username: '', name: '', - age: '', + dateOfBirth: '', gender: '', phone: '', password: '', @@ -41,7 +41,15 @@ const Signup = ({ onAuthSuccess = () => {} }) => { [form.username] ); const nameValid = form.name.trim().length >= 2; - const ageValid = form.age !== '' && parseInt(form.age, 10) > 12 && parseInt(form.age, 10) < 121; + + const dobValid = useMemo(() => { + if (!form.dateOfBirth) return false; + const dob = new Date(form.dateOfBirth); + const ageDate = new Date(Date.now() - dob.getTime()); + const calculatedAge = Math.abs(ageDate.getUTCFullYear() - 1970); + return calculatedAge > 12 && calculatedAge < 121; + }, [form.dateOfBirth]); + const genderValid = ['male', 'female', 'other', 'na'].includes(form.gender); const phoneValid = /^\+?[0-9]{10,15}$/.test(form.phone); const passwordValid = useMemo( @@ -50,7 +58,7 @@ const Signup = ({ onAuthSuccess = () => {} }) => { ); const confirmValid = form.confirm.length > 0 && form.confirm === form.password; - const isFormValid = usernameValid && nameValid && ageValid && genderValid && phoneValid && passwordValid && confirmValid; + const isFormValid = usernameValid && nameValid && dobValid && genderValid && phoneValid && passwordValid && confirmValid; const onChange = (e) => { const { name, value } = e.target; @@ -74,7 +82,7 @@ const Signup = ({ onAuthSuccess = () => {} }) => { setTouched({ username: true, name: true, - age: true, + dateOfBirth: true, gender: true, phone: true, password: true, @@ -92,7 +100,7 @@ const Signup = ({ onAuthSuccess = () => {} }) => { const payload = { username: normalizedUsername, name: form.name.trim(), - age: parseInt(form.age, 10), + date_of_birth: form.dateOfBirth, gender: form.gender, phone: form.phone, password: form.password, @@ -178,22 +186,25 @@ const Signup = ({ onAuthSuccess = () => {} }) => {
- + - {touched.age && !ageValid && ( -

{t('auth:errors.ageInvalid', 'Age must be between 13 and 120')}

+ {touched.dateOfBirth && !dobValid && ( +

+ {t('auth:errors.dobInvalid', 'You must be between 13 and 120 years old')} +

)}
@@ -214,7 +225,9 @@ const Signup = ({ onAuthSuccess = () => {} }) => { {touched.gender && !genderValid && ( -

{t('auth:errors.genderRequired', 'Please select a gender')}

+

+ {t('auth:errors.genderRequired', 'Please select a gender')} +

)}
diff --git a/frontend/src/pages/auth/Signup.test.jsx b/frontend/src/pages/auth/Signup.test.jsx index 3e90dcb..3666b54 100644 --- a/frontend/src/pages/auth/Signup.test.jsx +++ b/frontend/src/pages/auth/Signup.test.jsx @@ -4,6 +4,7 @@ import { screen, userEvent, waitFor, + fireEvent, } from '../../test/test-utils'; import Signup from './Signup'; @@ -76,14 +77,13 @@ describe('Signup', () => { }); it('shows error for invalid age', async () => { - const user = userEvent.setup(); renderSignup(); + + const dobInput = screen.getByLabelText(/date of birth/i); + fireEvent.change(dobInput, { target: { value: '2020-01-01' } }); + fireEvent.blur(dobInput); - const ageInput = screen.getByPlaceholderText(/age/i); - await user.type(ageInput, '10'); - await user.tab(); - - expect(screen.getByText(/age must be between 13 and 120/i)).toBeInTheDocument(); + expect(screen.getByText(/you must be between 13 and 120 years old/i)).toBeInTheDocument(); }); it('shows error for mismatched passwords', async () => { @@ -113,7 +113,7 @@ describe('Signup', () => { const fillValidForm = async (user) => { await user.type(screen.getByLabelText(/username/i), 'john_doe'); await user.type(screen.getByLabelText(/full name/i), 'John Doe'); - await user.type(screen.getByPlaceholderText(/age/i), '25'); + fireEvent.change(screen.getByLabelText(/date of birth/i), { target: { value: '2000-01-01' } }); await user.selectOptions(screen.getByRole('combobox'), 'male'); await user.type(screen.getByPlaceholderText(/phone number/i), '1234567890'); await user.type(screen.getByLabelText(/^password$/i), 'Password123'); @@ -142,7 +142,7 @@ describe('Signup', () => { expect(mockSignup).toHaveBeenCalledWith({ username: 'john_doe', name: 'John Doe', - age: 25, + date_of_birth: '2000-01-01', gender: 'male', phone: '1234567890', password: 'Password123', @@ -189,16 +189,18 @@ describe('Signup', () => { await user.type(screen.getByLabelText(/username/i), 'john_doe'); await user.type(screen.getByLabelText(/full name/i), 'John Doe'); - await user.type(screen.getByPlaceholderText(/age/i), '25'); + fireEvent.change(screen.getByLabelText(/date of birth/i), { target: { value: '2000-01-01' } }); await user.selectOptions(screen.getByRole('combobox'), 'male'); - - // Try to type letters - they should be stripped + const phoneInput = screen.getByPlaceholderText(/phone number/i); - await user.type(phoneInput, '123abc4567890'); - - await user.type(screen.getByLabelText(/^password$/i), 'Password123'); - await user.type(screen.getByLabelText(/confirm password/i), 'Password123'); - await user.click(screen.getByRole('button', { name: /sign up/i })); + await user.type(phoneInput, '123-456-7890'); + + await user.type(screen.getByLabelText(/^password$/i), 'Password123!'); + await user.type(screen.getByLabelText(/confirm password/i), 'Password123!'); + + const submitButton = screen.getByRole('button', { name: /sign up/i }); + expect(submitButton).toBeEnabled(); + await user.click(submitButton); await waitFor(() => { expect(mockSignup).toHaveBeenCalledWith( diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js index dca8ba0..8dd275e 100644 --- a/frontend/tailwind.config.js +++ b/frontend/tailwind.config.js @@ -5,7 +5,20 @@ export default { "./src/**/*.{js,ts,jsx,tsx}", ], theme: { - extend: {}, + extend: { + colors: { + + health: { + primary: '#0f766e', + secondary: '#059669', + good: '#10b981', + warning: '#f59e0b', + critical: '#ef4444', + surface: '#f0fdfa', + + } + }, }, plugins: [], } +} \ No newline at end of file From b76a324ac4354432d1de7a36e157c49693429ab5 Mon Sep 17 00:00:00 2001 From: Moon <195389365+Moon-dg@users.noreply.github.com> Date: Mon, 19 Oct 2026 13:46:17 -0500 Subject: [PATCH 2/4] chore: trigger PR mergeability check From 2cc88e79b0fa8793c1dfbb7ed740ec1888d9e7cc Mon Sep 17 00:00:00 2001 From: Moon <195389365+Moon-dg@users.noreply.github.com> Date: Mon, 26 Oct 2026 15:38:54 -0500 Subject: [PATCH 3/4] fix: address review comments on DOB validation, test imports, and tailwind config --- frontend/src/pages/auth/Signup.jsx | 15 +++++---------- frontend/src/utils/validation.js | 16 ++++++++++++++++ frontend/tailwind.config.js | 6 ++---- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/frontend/src/pages/auth/Signup.jsx b/frontend/src/pages/auth/Signup.jsx index 7362541..3afa2ab 100644 --- a/frontend/src/pages/auth/Signup.jsx +++ b/frontend/src/pages/auth/Signup.jsx @@ -6,6 +6,7 @@ import { useAuth } from '../../hooks/useAuth'; import { userHasValidHealthConsent } from '../../lib/consentConstants'; import { showErrorToast } from '../../lib/toast'; import { + isValidDateOfBirth, normalizeUsername, validatePassword, validateUsername, @@ -42,13 +43,7 @@ const Signup = ({ onAuthSuccess = () => {} }) => { ); const nameValid = form.name.trim().length >= 2; - const dobValid = useMemo(() => { - if (!form.dateOfBirth) return false; - const dob = new Date(form.dateOfBirth); - const ageDate = new Date(Date.now() - dob.getTime()); - const calculatedAge = Math.abs(ageDate.getUTCFullYear() - 1970); - return calculatedAge > 12 && calculatedAge < 121; - }, [form.dateOfBirth]); + const dateOfBirthValid = isValidDateOfBirth(form.dateOfBirth); const genderValid = ['male', 'female', 'other', 'na'].includes(form.gender); const phoneValid = /^\+?[0-9]{10,15}$/.test(form.phone); @@ -58,7 +53,7 @@ const Signup = ({ onAuthSuccess = () => {} }) => { ); const confirmValid = form.confirm.length > 0 && form.confirm === form.password; - const isFormValid = usernameValid && nameValid && dobValid && genderValid && phoneValid && passwordValid && confirmValid; + const isFormValid = usernameValid && nameValid && dateOfBirthValid && genderValid && phoneValid && passwordValid && confirmValid; const onChange = (e) => { const { name, value } = e.target; @@ -193,7 +188,7 @@ const Signup = ({ onAuthSuccess = () => {} }) => { id="dateOfBirth" type="date" className={`w-full border rounded px-3 py-2 ${ - touched.dateOfBirth && !dobValid ? 'border-red-500' : 'border-gray-300' + touched.dateOfBirth && !dateOfBirthValid ? 'border-red-500' : 'border-gray-300' }`} name="dateOfBirth" value={form.dateOfBirth} @@ -201,7 +196,7 @@ const Signup = ({ onAuthSuccess = () => {} }) => { onBlur={onBlur} max={new Date().toISOString().split("T")[0]} /> - {touched.dateOfBirth && !dobValid && ( + {touched.dateOfBirth && !dateOfBirthValid && (

{t('auth:errors.dobInvalid', 'You must be between 13 and 120 years old')}

diff --git a/frontend/src/utils/validation.js b/frontend/src/utils/validation.js index febdc0d..5864e28 100644 --- a/frontend/src/utils/validation.js +++ b/frontend/src/utils/validation.js @@ -34,3 +34,19 @@ export const validatePassword = (value) => { return checks.hasUppercase && checks.hasNumber; }; +export const isValidDateOfBirth = (value) => { + if (!value) return false; + const dob = new Date(value); + if (Number.isNaN(dob.getTime())) return false; + const today = new Date(); + let age = today.getFullYear() - dob.getFullYear(); + const m = today.getMonth() - dob.getMonth(); + if (m < 0 || (m === 0 && today.getDate() < dob.getDate())) { + age--; + } + return age >= 13 && age <= 120; +}; + +export const formatDateForInput = (date = new Date()) => { + return date.toISOString().split('T')[0]; +}; diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js index 8dd275e..20ce38c 100644 --- a/frontend/tailwind.config.js +++ b/frontend/tailwind.config.js @@ -7,7 +7,6 @@ export default { theme: { extend: { colors: { - health: { primary: '#0f766e', secondary: '#059669', @@ -15,10 +14,9 @@ export default { warning: '#f59e0b', critical: '#ef4444', surface: '#f0fdfa', - - } + } + }, }, }, plugins: [], -} } \ No newline at end of file From 9bed2a28169359dbc113941477109487b18682af Mon Sep 17 00:00:00 2001 From: Moon <195389365+Moon-dg@users.noreply.github.com> Date: Mon, 2 Nov 2026 16:24:30 -0600 Subject: [PATCH 4/4] fix: resolve duplicate imports and update date of birth required validation test --- frontend/src/pages/auth/Signup.jsx | 1 - frontend/src/pages/auth/Signup.test.jsx | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/auth/Signup.jsx b/frontend/src/pages/auth/Signup.jsx index 9f7159e..f8cf734 100644 --- a/frontend/src/pages/auth/Signup.jsx +++ b/frontend/src/pages/auth/Signup.jsx @@ -6,7 +6,6 @@ import { useAuth } from '../../hooks/useAuth'; import { userHasValidHealthConsent } from '../../lib/consentConstants'; import { showErrorToast } from '../../lib/toast'; import { - isValidDateOfBirth, normalizeUsername, validatePassword, validateUsername, diff --git a/frontend/src/pages/auth/Signup.test.jsx b/frontend/src/pages/auth/Signup.test.jsx index 4551e63..05b9da7 100644 --- a/frontend/src/pages/auth/Signup.test.jsx +++ b/frontend/src/pages/auth/Signup.test.jsx @@ -5,7 +5,6 @@ import { screen, userEvent, waitFor, - fireEvent, } from '../../test/test-utils'; import Signup from './Signup'; @@ -80,15 +79,11 @@ describe('Signup', () => { }); it('requires a date of birth', async () => { - const user = userEvent.setup(); renderSignup(); - const dobInput = screen.getByLabelText(/date of birth/i); - fireEvent.change(dobInput, { target: { value: '2020-01-01' } }); - fireEvent.blur(dobInput); - screen.getByLabelText(/date of birth/i).focus(); - await user.tab(); + fireEvent.focus(dobInput); + fireEvent.blur(dobInput); expect(screen.getByText(/date of birth is required/i)).toBeInTheDocument(); });