diff --git a/libs/client/features/src/onboarding/steps/Profile.tsx b/libs/client/features/src/onboarding/steps/Profile.tsx index 1bb5d704..99369341 100644 --- a/libs/client/features/src/onboarding/steps/Profile.tsx +++ b/libs/client/features/src/onboarding/steps/Profile.tsx @@ -92,7 +92,7 @@ type ProfileViewProps = { function ProfileForm({ title, onSubmit, defaultValues }: ProfileViewProps) { const [currentQuestion, setCurrentQuestion] = useState< 'birthday' | 'household' | 'residence' | 'goals' - >('birthday') + >('residence') const { control, @@ -122,98 +122,13 @@ function ProfileForm({ title, onSubmit, defaultValues }: ProfileViewProps) { to building plans or receiving advice from our advisors.

- When’s your birthday?} - onClick={() => setCurrentQuestion('birthday')} - next={() => setCurrentQuestion('household')} - > - - BrowserUtil.validateFormDate(d, { - minDate: DateTime.now().minus({ years: 100 }).toISODate(), - required: true, - }), - }} - render={({ field, fieldState: { error } }) => ( - - )} - /> - - We use your age to personalize plans to your context instead of - showing years when referring to future events. “Retire at - 45” sounds better than “Retire in 2043”. - - } - > -
- - Why do we need your age? -
-
-
- - setCurrentQuestion('household')} - back={() => setCurrentQuestion('birthday')} - next={() => setCurrentQuestion('residence')} - > -
- ( - <> - {Object.entries({ - single: 'Single income, no dependents', - singleWithDependents: - 'Single income, at least one dependent', - dual: 'Dual income, no dependents', - dualWithDependents: 'Dual income, at least one dependent', - retired: 'Retired or financially independent', - }).map(([value, label]) => ( - { - if (checked) field.onChange(value) - }} - /> - ))} - - )} - /> -
-
- setCurrentQuestion('residence')} - back={() => setCurrentQuestion('household')} - next={() => setCurrentQuestion('goals')} + next={() => setCurrentQuestion('birthday')} >
+ When’s your birthday?} + onClick={() => setCurrentQuestion('birthday')} + next={() => setCurrentQuestion('household')} + back={() => setCurrentQuestion('residence')} + > + + BrowserUtil.validateFormDate(d, { + minDate: DateTime.now().minus({ years: 100 }).toISODate(), + required: true, + }), + }} + render={({ field, fieldState: { error } }) => ( + + )} + /> + + We use your age to personalize plans to your context instead of + showing years when referring to future events. “Retire at + 45” sounds better than “Retire in 2043”. + + } + > +
+ + Why do we need your age? +
+
+
+ + setCurrentQuestion('household')} + back={() => setCurrentQuestion('birthday')} + next={() => setCurrentQuestion('goals')} + > +
+ ( + <> + {Object.entries({ + single: 'Single income, no dependents', + singleWithDependents: + 'Single income, at least one dependent', + dual: 'Dual income, no dependents', + dualWithDependents: 'Dual income, at least one dependent', + retired: 'Retired or financially independent', + }).map(([value, label]) => ( + { + if (checked) field.onChange(value) + }} + /> + ))} + + )} + /> +
+
keyword.trim()) + .join('') + .split('') + .map((keyword) => keyword.toUpperCase()) +} + +function getDateFormatPattern(dateFormat: string): string { + const dateComponents = dateFormat.split('/') + const pattern = dateComponents + .map((component) => { + if (component.includes('d')) { + return ' ## ' // Placeholder for day + } else if (component.includes('m') || component.includes('M')) { + return ' ## ' // Placeholder for month + } else if (component.includes('y')) { + return ' #### ' // Placeholder for year + } + return component // Keep non-date components unchanged + }) + .join('/') + .trim() + + return pattern } function DatePicker( @@ -45,6 +75,7 @@ function DatePicker( maxCalendarDate = MAX_SUPPORTED_DATE.toISODate(), popperPlacement = 'auto', popperStrategy = 'fixed', + dateFormat = DEFAULT_INPUT_DATE_FORMAT, }: DatePickerProps, ref: Ref ): JSX.Element { @@ -79,15 +110,14 @@ function DatePicker( setCalendarValue('') onChange(null) } else { - const inputDate = DateTime.fromFormat(date.formattedValue, INPUT_DATE_FORMAT) - + const inputDate = DateTime.fromFormat(date.formattedValue, dateFormat) if (inputDate.isValid) { setCalendarValue(inputDate.toISODate()) onChange(inputDate.toISODate()) } } }, - [onChange] + [onChange, dateFormat] ) return ( @@ -97,10 +127,10 @@ function DatePicker( name={name} customInput={Input} // passes all props below to - https://github.com/s-yadav/react-number-format#custom-inputs getInputRef={ref} - format="## / ## / ####" + format={getDateFormatPattern(dateFormat)} placeholder={placeholder} - mask={['M', 'M', 'D', 'D', 'Y', 'Y', 'Y', 'Y']} - value={toFormattedStr(value)} + mask={getMaskArray(dateFormat)} + value={toFormattedStr(value, dateFormat)} error={error} label={label} onValueChange={handleInputValueChange}