Onboarding
This commit is contained in:
44
services/onboardingProgressService.ts
Normal file
44
services/onboardingProgressService.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { OnboardingProfileDb } from './database';
|
||||
|
||||
export type PersistentOnboardingStep = 'lexicon' | 'customize';
|
||||
|
||||
export const OnboardingProgressService = {
|
||||
isStepCompleted(userId: number, step: PersistentOnboardingStep): boolean {
|
||||
const profile = OnboardingProfileDb.get(userId);
|
||||
return step === 'lexicon'
|
||||
? profile.lexicon_explored === 1
|
||||
: profile.customization_done === 1;
|
||||
},
|
||||
|
||||
completeStep(userId: number, step: PersistentOnboardingStep): void {
|
||||
if (step === 'lexicon') {
|
||||
OnboardingProfileDb.setLexiconExplored(userId, true);
|
||||
return;
|
||||
}
|
||||
OnboardingProfileDb.setCustomizationDone(userId, true);
|
||||
},
|
||||
|
||||
getSignals(userId: number) {
|
||||
const profile = OnboardingProfileDb.get(userId);
|
||||
return {
|
||||
lexiconExplored: profile.lexicon_explored === 1,
|
||||
customizationDone: profile.customization_done === 1,
|
||||
};
|
||||
},
|
||||
|
||||
getAcquisitionSource(userId: number): string | null {
|
||||
return OnboardingProfileDb.get(userId).acquisition_source;
|
||||
},
|
||||
|
||||
setAcquisitionSource(userId: number, source: string): void {
|
||||
OnboardingProfileDb.setAcquisitionSource(userId, source);
|
||||
},
|
||||
|
||||
setPrimaryGoal(userId: number, goal: string): void {
|
||||
OnboardingProfileDb.setPrimaryGoal(userId, goal);
|
||||
},
|
||||
|
||||
setExperienceLevel(userId: number, level: string): void {
|
||||
OnboardingProfileDb.setExperienceLevel(userId, level);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user