setting up test functionality

This commit is contained in:
masongga
2026-05-23 16:47:42 -06:00
parent 2ad9e42f3f
commit 94dbd18946
27 changed files with 1451 additions and 230 deletions

View File

@@ -0,0 +1,52 @@
import { notifyHabitPetDataUpdated } from "@/lib/app-events";
export type ProfilePreferences = {
focusTopics: string[];
avatarVibe: string;
dailyReminderEnabled: boolean;
dailyReminderTime: string;
};
const STORAGE_KEY = "habit-pet-profile-preferences";
export const focusTopicOptions = [
"Sleep",
"Movement",
"Hydration",
"Mindfulness",
] as const;
export const avatarVibeOptions = ["Calm", "Energetic", "Curious", "Cozy"] as const;
export const defaultProfilePreferences: ProfilePreferences = {
focusTopics: ["Movement"],
avatarVibe: "Calm",
dailyReminderEnabled: false,
dailyReminderTime: "20:00",
};
export function getProfilePreferences(): ProfilePreferences {
if (typeof window === "undefined") {
return defaultProfilePreferences;
}
const raw = window.localStorage.getItem(STORAGE_KEY);
if (!raw) {
return defaultProfilePreferences;
}
try {
return {
...defaultProfilePreferences,
...(JSON.parse(raw) as Partial<ProfilePreferences>),
};
} catch {
return defaultProfilePreferences;
}
}
export function saveProfilePreferences(preferences: ProfilePreferences) {
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(preferences));
notifyHabitPetDataUpdated();
}