feat: implement mentor registration form and API integration#259
Conversation
…nity/main Fix mentee registration form (Women-Coding-Community#248)
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.
womencodingcommunity
left a comment
There was a problem hiding this comment.
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:
hoursinlongTermis silently computed asnumMentees × 2with no UI input — the assumption should be at minimum made explicit with a named constant and a TODO (see inline).Cache-Control: no-cacheheaders 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: anywitharea.technicalArea || area.namedead-branch fallbacks — theanycast and the dead fallbacks can be removed now that the schema defines the shape unambiguously.parseInt(data.yearsExperience as any as string, 10)—yearsExperienceis already anumberafter 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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
…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
|



Description
This PR implements the mentor registration flow end-to-end, connecting the multi-step form to the backend platform API.
Type
Screenshots
Testing
Unit tests were added for the
mentor-registrationandmentee-registrationAPI routes (src/__tests__/api/), and for the mentor Zod schema(
src/schemas/__tests__/mentorSchema.test.ts). Theapi.test.tswas refactored to useasync import()instead ofrequire()to comply withthe project's ESLint rules.
Pull request checklist
Please check if your PR fulfills the following requirements: