Skip to content

feat(onboarding) - add new step to select country #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

gabrielseco
Copy link
Collaborator

@gabrielseco gabrielseco commented May 29, 2025

I added a new step to select country and remove the countryId from the props.

We could discuss later if we could have countryId as optional to preselect the country fields

You can select a country and the onboarding starts as before

If you decide to load an onboarding and you change countries, in the basic information step we don't update the employment, we just create a new one.

@gabrielseco gabrielseco changed the title Pbyr 2530 create a first step of the form that lets you select a feat(onboarding) - add new step to select country May 30, 2025
@gabrielseco gabrielseco requested a review from eng-almeida May 30, 2025 12:33
@gabrielseco gabrielseco self-assigned this May 30, 2025
@gabrielseco gabrielseco removed the request for review from eng-almeida May 30, 2025 12:40
@gabrielseco gabrielseco marked this pull request as ready for review May 30, 2025 14:01
@gabrielseco gabrielseco requested a review from eng-almeida May 30, 2025 14:01
Comment on lines 507 to 509
return parseJSFToValidate(values, selectCountryForm?.fields, {
isPartialValidation: true,
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to parse the country values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did for what I thought it was consistency, I've removed it

const [internalCountryCode, setInternalCountryCode] = useState<string | null>(
null,
);
const { data: countries, isLoading: isLoadingCountries } = useCountries();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we build a hook that aggregates all the logic to build the country dropdown? It could do what useCountries already does and in the select callback run createHeadlessForm for the local schema

@@ -554,6 +637,13 @@ export const useOnboarding = ({
* @returns Validation result or null if no schema is available
*/
handleValidation: (values: FieldValues) => {
if (stepState.currentStep.name === 'select_country') {
const parsedValues = parseJSFToValidate(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question, do we need to parse the country value?

case 'basic_information': {
if (!internalEmploymentId) {
const notLoadedEmployment =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be consistent in the naming, so booleans should start with is, eg isEmploymentLoaded

@gabrielseco gabrielseco merged commit 737635c into main Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants