Onboarding

This commit is contained in:
2026-07-16 17:09:00 +02:00
parent 5c09c50af9
commit 52c9dfb472
5 changed files with 935 additions and 809 deletions

View File

@@ -1,21 +1,31 @@
import { OnboardingProfileDb } from './database';
export type PersistentOnboardingStep = 'lexicon' | 'customize';
export type PersistentOnboardingStep = 'lexicon' | 'customize' | 'scan' | 'reminder' | 'collection';
const STEP_COLUMN: Record<PersistentOnboardingStep, 'lexicon_explored' | 'customization_done' | 'scan_done' | 'reminder_done' | 'collection_done'> = {
lexicon: 'lexicon_explored',
customize: 'customization_done',
scan: 'scan_done',
reminder: 'reminder_done',
collection: 'collection_done',
};
const STEP_SETTER: Record<PersistentOnboardingStep, (userId: number, done: boolean) => void> = {
lexicon: OnboardingProfileDb.setLexiconExplored,
customize: OnboardingProfileDb.setCustomizationDone,
scan: OnboardingProfileDb.setScanDone,
reminder: OnboardingProfileDb.setReminderDone,
collection: OnboardingProfileDb.setCollectionDone,
};
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;
return profile[STEP_COLUMN[step]] === 1;
},
completeStep(userId: number, step: PersistentOnboardingStep): void {
if (step === 'lexicon') {
OnboardingProfileDb.setLexiconExplored(userId, true);
return;
}
OnboardingProfileDb.setCustomizationDone(userId, true);
STEP_SETTER[step](userId, true);
},
getSignals(userId: number) {
@@ -23,6 +33,9 @@ export const OnboardingProgressService = {
return {
lexiconExplored: profile.lexicon_explored === 1,
customizationDone: profile.customization_done === 1,
scanDone: profile.scan_done === 1,
reminderDone: profile.reminder_done === 1,
collectionDone: profile.collection_done === 1,
};
},