Spaces:
Runtime error
Runtime error
File size: 735 Bytes
c0a9bce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import { atom } from 'nanostores';
interface Profile {
username: string;
bio: string;
avatar: string;
}
// Initialize with stored profile or defaults
const storedProfile = typeof window !== 'undefined' ? localStorage.getItem('bolt_profile') : null;
const initialProfile: Profile = storedProfile
? JSON.parse(storedProfile)
: {
username: '',
bio: '',
avatar: '',
};
export const profileStore = atom<Profile>(initialProfile);
export const updateProfile = (updates: Partial<Profile>) => {
profileStore.set({ ...profileStore.get(), ...updates });
// Persist to localStorage
if (typeof window !== 'undefined') {
localStorage.setItem('bolt_profile', JSON.stringify(profileStore.get()));
}
};
|