/** * 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); }