diff --git a/src/screens/Signup/__tests__/state.test.ts b/src/screens/Signup/__tests__/state.test.ts index 7e7d54d97..81663de70 100644 --- a/src/screens/Signup/__tests__/state.test.ts +++ b/src/screens/Signup/__tests__/state.test.ts @@ -143,3 +143,9 @@ it('preserves a submission error when routing back to the field that needs corre expect(next.error).toBe('Handle unavailable') expect(next.errorField).toBe('handle') }) + +it('starts the birth date twenty years back, so the read-only row has a date to show and edit', () => { + const birth = initialState.dateOfBirth + expect(birth).toBeInstanceOf(Date) + expect(new Date().getFullYear() - (birth as Date).getFullYear()).toBe(20) +}) diff --git a/src/screens/Signup/state.ts b/src/screens/Signup/state.ts index 0ca13614d..176d5f5c5 100644 --- a/src/screens/Signup/state.ts +++ b/src/screens/Signup/state.ts @@ -16,6 +16,13 @@ import {com} from '#/lexicons' export type ServiceDescription = com.atproto.server.describeServer.$OutputBody +/* + * The signup form shows the birth date in a read-only row over a hidden date + * input, so it needs a starting value to display and to edit from. + */ +const DEFAULT_DATE = new Date() +DEFAULT_DATE.setFullYear(DEFAULT_DATE.getFullYear() - 20) + export enum SignupStep { COMMUNITY, INFO, @@ -98,7 +105,7 @@ export const initialState: SignupState = { serviceUrl: DEFAULT_SERVICE, serviceDescription: undefined, userDomain: '', - dateOfBirth: undefined, + dateOfBirth: DEFAULT_DATE, email: '', password: '', handle: '',