nxtgauge-frontend-solid/src/lib/guided-tour-content.ts

132 lines
4.4 KiB
TypeScript

import { normalizeRoleForTour } from './guided-tour';
export interface GuidedTourStep {
title: string;
body: string;
}
export interface RuntimeGuidedTours {
welcome?: GuidedTourStep[];
role_approved_default?: GuidedTourStep[];
roles?: Record<string, GuidedTourStep[]>;
}
const DEFAULT_WELCOME_STEPS: GuidedTourStep[] = [
{
title: 'Welcome to your Nxtgauge dashboard',
body: 'This is your home base. You can explore options and start your first onboarding flow from here.',
},
{
title: 'Choose what you want to do',
body: 'Use "Choose What You Need" or "Explore Nxtgauge" to select a path that matches your goal.',
},
{
title: 'Track your progress',
body: 'You can always return to check status updates, notifications, and your profile in one place.',
},
];
const DEFAULT_COMPANY_APPROVED_STEPS: GuidedTourStep[] = [
{
title: 'Your company profile is approved',
body: 'You can now create job posts and manage hiring activity from your company dashboard.',
},
{
title: 'Start with job postings',
body: 'Go to Jobs to create or update postings and send them for admin approval when required.',
},
{
title: 'Review incoming applications',
body: 'Use Applications to shortlist, reject, and progress candidates through your hiring flow.',
},
];
const DEFAULT_CUSTOMER_APPROVED_STEPS: GuidedTourStep[] = [
{
title: 'Your customer profile is approved',
body: 'You now have access to requirement workflows and can connect with verified professionals.',
},
{
title: 'Share your requirements',
body: 'Create requirements with your details, timeline, and budget to receive relevant responses.',
},
{
title: 'Track and manage responses',
body: 'Use marketplace and request views to compare professionals and move forward confidently.',
},
];
const DEFAULT_JOB_SEEKER_APPROVED_STEPS: GuidedTourStep[] = [
{
title: 'Your job seeker profile is approved',
body: 'You can now browse jobs and apply directly from your dashboard.',
},
{
title: 'Find opportunities faster',
body: 'Use job filters and details pages to focus on roles that match your goals.',
},
{
title: 'Track every application',
body: 'Check your applications panel for shortlist, interview, and offer updates.',
},
];
function isValidStepArray(value: unknown): value is GuidedTourStep[] {
return (
Array.isArray(value) &&
value.length > 0 &&
value.every(
(step) =>
step &&
typeof step === 'object' &&
typeof (step as GuidedTourStep).title === 'string' &&
typeof (step as GuidedTourStep).body === 'string',
)
);
}
function prettyRoleName(role: string): string {
const normalized = normalizeRoleForTour(role);
if (!normalized) return 'professional';
return normalized.toLowerCase().replaceAll('_', ' ');
}
function defaultProfessionalApprovedSteps(role: string): GuidedTourStep[] {
const roleName = prettyRoleName(role);
return [
{
title: `Your ${roleName} profile is approved`,
body: 'Your role-specific dashboard is now unlocked with modules tailored to your work.',
},
{
title: 'Complete your public profile',
body: 'Update portfolio, services, and profile sections so customers and companies can trust your expertise.',
},
{
title: 'Respond and grow',
body: 'Track incoming leads or opportunities, and use your dashboard tools to convert them into outcomes.',
},
];
}
export function resolveWelcomeTourSteps(runtimeTours?: RuntimeGuidedTours | null): GuidedTourStep[] {
if (isValidStepArray(runtimeTours?.welcome)) return runtimeTours!.welcome;
return DEFAULT_WELCOME_STEPS;
}
export function resolveRoleApprovedTourSteps(
role: string | null | undefined,
runtimeTours?: RuntimeGuidedTours | null,
): GuidedTourStep[] {
const normalizedRole = normalizeRoleForTour(role);
if (!normalizedRole || normalizedRole === 'USER') return [];
const roleOverride = runtimeTours?.roles?.[normalizedRole];
if (isValidStepArray(roleOverride)) return roleOverride;
if (isValidStepArray(runtimeTours?.role_approved_default)) return runtimeTours!.role_approved_default;
if (normalizedRole === 'COMPANY') return DEFAULT_COMPANY_APPROVED_STEPS;
if (normalizedRole === 'CUSTOMER') return DEFAULT_CUSTOMER_APPROVED_STEPS;
if (normalizedRole === 'JOB_SEEKER') return DEFAULT_JOB_SEEKER_APPROVED_STEPS;
return defaultProfessionalApprovedSteps(normalizedRole);
}