Skip to content

feat: implement mentor registration form and API integration#259

Merged
dricazenck merged 9 commits intoWomen-Coding-Community:mainfrom
dricazenck:feat/mentor_registration
Mar 29, 2026
Merged

feat: implement mentor registration form and API integration#259
dricazenck merged 9 commits intoWomen-Coding-Community:mainfrom
dricazenck:feat/mentor_registration

Conversation

@dricazenck
Copy link
Copy Markdown
Collaborator

Description

This PR implements the mentor registration flow end-to-end, connecting the multi-step form to the backend platform API.

Type

  • New Feature
  • Bug Fix

Screenshots

  • Validation Error:
image - Step 3 image - Step 4 image - The registration success screen (updated button label and destination) success_mentor
  • mentor in the backend
mentor_long_term

Testing

Unit tests were added for the mentor-registration and mentee-registration API routes (src/__tests__/api/), and for the mentor Zod schema
(src/schemas/__tests__/mentorSchema.test.ts). The api.test.ts was refactored to use async import() instead of require() to comply with
the project's ESLint rules.

Pull request checklist

Please check if your PR fulfills the following requirements:

  • I checked and followed the contributor guide
  • I have tested my changes locally.
  • I have added a screenshot from the website after I tested it locally

womencodingcommunity and others added 7 commits March 12, 2026 14:24
The original question framing ("do not identify as women") was negatively
worded and lacked context for mentors filling out the form. The new copy
adds a brief mission statement to help mentors understand the community's
priorities before answering, and replaces the bare "Yes/No" radio labels
with descriptive options that eliminate ambiguity. The aria-label is also
updated to remove the negative framing for screen reader users.
The mentor registration form previously had no real submission logic —
onSubmit only logged data to the console. This commit wires up the full
submission flow: a new /api/mentor-registration Next.js route maps the
frontend schema to the backend MentorDto and calls the platform API via a
new shared proxyRequest utility extracted into src/lib/api.ts. The
existing mentee-registration and mentors API routes are refactored to use
the same utility, eliminating duplicated env-var/header handling. Schema
fixes address adHocAvailability empty-value handling, and default values
are added to prevent uncontrolled-to-controlled input warnings. Step 3
and Step 4 validation are wired up, and loading/error UI states give the
user feedback during submission.
ESLint import-order requires the @utils alias import to precede relative
path imports. Auto-fixed by the pre-commit linter on the previous commit.
The mentor API route was sending month names (e.g. "JANUARY") where
the backend expects numeric values (1–12), and the identity check
used "Woman" where the updated form emits "Yes". This commit corrects
those mappings and adds the missing network/LinkedIn field to the
payload. The otherSocial type is corrected from DEFAULT_LINK to OTHER
to match the backend enum.

The mentor CTA on the mentorship index page now routes to the internal
/mentorship/mentor-registration page instead of the legacy Google Form,
and MentorBecomeCard's target="_blank" is removed for same-tab
navigation. The years-of-experience field is changed from a predefined
dropdown to a numeric input validated by Zod (min 2, max 50). The
post-submission success screen now links back to the mentorship page
instead of the home page.
Copy link
Copy Markdown
Contributor

@womencodingcommunity womencodingcommunity left a comment

Choose a reason for hiding this comment

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

This is a substantial and well-executed PR — the end-to-end registration flow, the proxyRequest abstraction that eliminates duplication across three API routes, the Zod schema improvements, and the per-step validation hooks all look solid. The submission loading/error/success states and the validation error summary in the UI are great UX additions, and the screenshots confirm it works well end-to-end.

Warnings to address before or shortly after merge:

  • hours in longTerm is silently computed as numMentees × 2 with no UI input — the assumption should be at minimum made explicit with a named constant and a TODO (see inline).
  • Cache-Control: no-cache headers were dropped from the mentors endpoint — if caching is unintentional, please restore them; if it is deliberate, add a comment explaining why (see inline).

Info / optional follow-ups (no blocker):

  • area: any with area.technicalArea || area.name dead-branch fallbacks — the any cast and the dead fallbacks can be removed now that the schema defines the shape unambiguously.
  • parseInt(data.yearsExperience as any as string, 10)yearsExperience is already a number after Zod coercion; the double cast is unnecessary.

if (data.otherSocial) network.push({ type: 'OTHER', link: data.otherSocial });

// Map PronounCategory
const pronounCategory = data.identity === 'Yes' ? 'FEMININE' : 'UNSPECIFIED';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For the pronounCategory, it will give us only two options available, but there are more based on API schema: Feminine, Masculine, Neutral, Multiple, Neopronouns, Any, Unspecified. Do we want to reduce number of options on backend side and add a few here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we should use all levels, but let's create another ticket to take care of that, for now. It was just to make work the mentor registration. I will create another ticket to fix that, ok?

Copy link
Copy Markdown
Contributor

@nora-weisser nora-weisser left a comment

Choose a reason for hiding this comment

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

I tested in the local, it works well! Later we can add some missing fields from backend request payload (like additional in mentee section and images)

…loud duplication warning

- Extract repeated error-handling catch block into shared handleApiError
  helper in lib/api.ts, eliminating duplication across three API routes
- Restore Cache-Control response header on GET /api/mentors to prevent
  stale mentor listings being served from CDN or Next.js cache
- Replace hardcoded HOURS_PER_MENTEE inline constant with named module-level
  constant and explanatory comment
- Remove any casts and dead fallbacks (area.name, lang.name, area.proficiency)
  from technicalAreas and codeLanguages mappings now that Zod schema defines
  the shape unambiguously
- Simplify yearsExperience mapping: field is already a number after Zod coercion
- Fix openToNonWomen pre-selected radio bug: replace z.enum+transform with
  z.boolean() and update RadioGroup onChange to propagate boolean values
- Fix Resolver type mismatch caused by z.coerce.number() producing unknown
  input type in Zod v4; add explanatory cast comment
- Update test fixtures: yearsExperience 5 as number, openToNonWomen as boolean
… into feat/mentor_registration

# Conflicts:
#	src/pages/mentorship/index.tsx
@sonarqubecloud
Copy link
Copy Markdown

@dricazenck dricazenck merged commit cf32727 into Women-Coding-Community:main Mar 29, 2026
3 of 5 checks passed
@dricazenck dricazenck deleted the feat/mentor_registration branch March 29, 2026 17:39
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