Testflight
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { OnboardingProgressService } from './onboardingProgressService';
|
||||
|
||||
const STORAGE_KEY = 'greenlens_preauth_onboarding_v1';
|
||||
|
||||
export type PreAuthAnswers = {
|
||||
acquisitionSource?: string;
|
||||
primaryGoal?: string;
|
||||
experienceLevel?: string;
|
||||
};
|
||||
|
||||
export const PreAuthOnboardingService = {
|
||||
async setAnswer<K extends keyof PreAuthAnswers>(key: K, value: PreAuthAnswers[K]): Promise<void> {
|
||||
const answers = await this.getAnswers();
|
||||
answers[key] = value;
|
||||
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(answers));
|
||||
},
|
||||
|
||||
async getAnswers(): Promise<PreAuthAnswers> {
|
||||
try {
|
||||
const raw = await AsyncStorage.getItem(STORAGE_KEY);
|
||||
return raw ? (JSON.parse(raw) as PreAuthAnswers) : {};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
|
||||
// Persist buffered answers into the per-user profile after sign-up/login.
|
||||
async flushToProfile(userId: number): Promise<void> {
|
||||
const answers = await this.getAnswers();
|
||||
if (answers.acquisitionSource) OnboardingProgressService.setAcquisitionSource(userId, answers.acquisitionSource);
|
||||
if (answers.primaryGoal) OnboardingProgressService.setPrimaryGoal(userId, answers.primaryGoal);
|
||||
if (answers.experienceLevel) OnboardingProgressService.setExperienceLevel(userId, answers.experienceLevel);
|
||||
await AsyncStorage.removeItem(STORAGE_KEY);
|
||||
},
|
||||
};
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { OnboardingProgressService } from './onboardingProgressService';
|
||||
|
||||
const STORAGE_KEY = 'greenlens_preauth_onboarding_v1';
|
||||
|
||||
export type PreAuthAnswers = {
|
||||
acquisitionSource?: string;
|
||||
primaryGoal?: string;
|
||||
experienceLevel?: string;
|
||||
};
|
||||
|
||||
export const PreAuthOnboardingService = {
|
||||
async setAnswer<K extends keyof PreAuthAnswers>(key: K, value: PreAuthAnswers[K]): Promise<void> {
|
||||
const answers = await this.getAnswers();
|
||||
answers[key] = value;
|
||||
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(answers));
|
||||
},
|
||||
|
||||
async getAnswers(): Promise<PreAuthAnswers> {
|
||||
try {
|
||||
const raw = await AsyncStorage.getItem(STORAGE_KEY);
|
||||
return raw ? (JSON.parse(raw) as PreAuthAnswers) : {};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
|
||||
// Persist buffered answers into the per-user profile after sign-up/login.
|
||||
async flushToProfile(userId: number): Promise<void> {
|
||||
const answers = await this.getAnswers();
|
||||
if (answers.acquisitionSource) OnboardingProgressService.setAcquisitionSource(userId, answers.acquisitionSource);
|
||||
if (answers.primaryGoal) OnboardingProgressService.setPrimaryGoal(userId, answers.primaryGoal);
|
||||
if (answers.experienceLevel) OnboardingProgressService.setExperienceLevel(userId, answers.experienceLevel);
|
||||
await AsyncStorage.removeItem(STORAGE_KEY);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user