All checks were successful
build-and-release / build (push) Successful in 1m44s
- Show RoleWizard inline in SwitchServicesPage immediately after role registration — no separate navigate-to-profile step - Pre-fill shared identity docs (Aadhaar, PAN, selfie, address proof) from the user's active role profile so they don't re-upload on a second role registration - Add identity_shared: boolean to RuntimeOnboardingField type so admins can mark fields in the Onboarding Schema Editor; CONVENTION_IDENTITY_ FIELD_IDS covers common IDs automatically as a fallback - Extract roleKeyToPrefix() into src/lib/role-utils.ts shared utility - FileControl sub-component keeps reactivity clean (no any casts) - Fix solid/reactivity: snapshot form()/docUrls()/portfolioForm() synchronously before the first await in handleSubmit/savePortfolio - Reuse badge (♻ indigo) distinguishes pre-filled docs from new uploads; Change link clears pre-fill so user can re-upload - Pending roles now show 'Under Review' badge; wizard exits via ArrowLeft Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
/**
|
|
* Shared role utilities used by ProfilePage, SwitchServicesPage, and any
|
|
* other page that needs to map a role key to an API path prefix.
|
|
*/
|
|
|
|
/**
|
|
* Maps a role key (e.g. "PHOTOGRAPHER") to the API path prefix used by that
|
|
* role's backend service (e.g. "photographers").
|
|
*
|
|
* Must stay in sync with the Axum router mounts in
|
|
* nxtgauge-backend-rust/apps/gateway/src/main.rs.
|
|
*/
|
|
export function roleKeyToPrefix(roleKey: string): string {
|
|
switch (roleKey) {
|
|
case "JOB_SEEKER": return "job-seekers";
|
|
case "COMPANY": return "company";
|
|
case "CATERING_SERVICES": return "catering-services";
|
|
case "MAKEUP_ARTIST": return "makeup-artists";
|
|
default:
|
|
// PHOTOGRAPHER → photographers, DEVELOPER → developers, etc.
|
|
return roleKey.toLowerCase().replace(/_/g, "-") + "s";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Field IDs that are considered "shared identity" documents by convention
|
|
* when the onboarding schema has not explicitly marked them with
|
|
* `identity_shared: true`. Admins can use these IDs to get automatic
|
|
* pre-fill from the user's active role — or they can mark any field with
|
|
* `identity_shared: true` to opt into pre-fill explicitly.
|
|
*/
|
|
export const CONVENTION_IDENTITY_FIELD_IDS = new Set([
|
|
"aadhaar",
|
|
"aadhaar_card",
|
|
"aadhaar_number",
|
|
"aadhar",
|
|
"pan",
|
|
"pan_card",
|
|
"pan_number",
|
|
"passport",
|
|
"passport_number",
|
|
"selfie",
|
|
"profile_photo",
|
|
"photo_id",
|
|
"address_proof",
|
|
"government_id",
|
|
]);
|
|
|
|
/**
|
|
* Returns true when a field should be pre-filled from the user's existing
|
|
* profile across roles (either admin-flagged or matched by convention).
|
|
*/
|
|
export function isIdentityField(fieldId: string, adminFlagged: boolean): boolean {
|
|
return adminFlagged || CONVENTION_IDENTITY_FIELD_IDS.has(fieldId);
|
|
}
|