mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
- Move stores/utils/types to their relative directories (i.e chat stores in chat directory) - Move utility files to shared/utils - Move component files to shared/components - Move type definitions to shared/types - Move stores to shared/stores - Update import paths across the project
29 lines
735 B
TypeScript
29 lines
735 B
TypeScript
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()));
|
|
}
|
|
};
|