mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-21 18:06:41 +02:00
- Move finance, mail, moodlit to apps-archived for later development - Rename games/voxel-lava to games/voxelava 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
66 lines
1.3 KiB
TypeScript
66 lines
1.3 KiB
TypeScript
/**
|
|
* User Settings Store for Finance
|
|
* Manages user preferences and settings
|
|
*/
|
|
|
|
interface UserSettings {
|
|
currency: string;
|
|
locale: string;
|
|
dateFormat: string;
|
|
nav: {
|
|
desktopPosition: 'left' | 'center' | 'right';
|
|
};
|
|
}
|
|
|
|
const defaultSettings: UserSettings = {
|
|
currency: 'EUR',
|
|
locale: 'de',
|
|
dateFormat: 'dd.MM.yyyy',
|
|
nav: {
|
|
desktopPosition: 'center',
|
|
},
|
|
};
|
|
|
|
let settings = $state<UserSettings>({ ...defaultSettings });
|
|
let isLoaded = $state(false);
|
|
|
|
export const userSettings = {
|
|
get currency() {
|
|
return settings.currency;
|
|
},
|
|
get locale() {
|
|
return settings.locale;
|
|
},
|
|
get dateFormat() {
|
|
return settings.dateFormat;
|
|
},
|
|
get nav() {
|
|
return settings.nav;
|
|
},
|
|
get isLoaded() {
|
|
return isLoaded;
|
|
},
|
|
|
|
async load() {
|
|
if (typeof window === 'undefined') return;
|
|
|
|
// Load from localStorage
|
|
const saved = localStorage.getItem('finance-user-settings');
|
|
if (saved) {
|
|
try {
|
|
const parsed = JSON.parse(saved);
|
|
settings = { ...defaultSettings, ...parsed };
|
|
} catch {
|
|
// Ignore parse errors
|
|
}
|
|
}
|
|
isLoaded = true;
|
|
},
|
|
|
|
update(updates: Partial<UserSettings>) {
|
|
settings = { ...settings, ...updates };
|
|
if (typeof localStorage !== 'undefined') {
|
|
localStorage.setItem('finance-user-settings', JSON.stringify(settings));
|
|
}
|
|
},
|
|
};
|