diff --git a/src/app/dashboard/settings/locale/page.tsx b/src/app/dashboard/settings/locale/page.tsx new file mode 100644 index 0000000..ba6ba27 --- /dev/null +++ b/src/app/dashboard/settings/locale/page.tsx @@ -0,0 +1,149 @@ +'use client'; + +import { useState, useEffect } from 'react'; + +const LANGUAGES = [ + { code: 'ro', label: 'Română', flag: '🇷🇴' }, + { code: 'en', label: 'English', flag: '🇬🇧' }, + { code: 'de', label: 'Deutsch', flag: '🇩🇪' }, + { code: 'es', label: 'Español', flag: '🇪🇸' }, +]; + +const TIMEZONES = [ + { value: 'Europe/Bucharest', label: 'Europa/București (EET/EEST)' }, + { value: 'Europe/Berlin', label: 'Europa/Berlin (CET/CEST)' }, + { value: 'Europe/London', label: 'Europa/Londra (GMT/BST)' }, + { value: 'America/New_York', label: 'SUA/New York (EST/EDT)' }, + { value: 'UTC', label: 'UTC' }, +]; + +const DATE_FORMATS = [ + { value: 'dd.MM.yyyy', label: '01.08.2026 (România)' }, + { value: 'MM/dd/yyyy', label: '08/01/2026 (SUA)' }, + { value: 'yyyy-MM-dd', label: '2026-08-01 (ISO)' }, + { value: 'dd/MM/yyyy', label: '01/08/2026 (UK)' }, +]; + +const CURRENCIES = [ + { code: 'RON', label: 'Leu românesc (RON)' }, + { code: 'EUR', label: 'Euro (EUR)' }, + { code: 'USD', label: 'Dolar american (USD)' }, + { code: 'GBP', label: 'Liră sterlină (GBP)' }, +]; + +const STORAGE_KEY = 'ceo-os:locale-preferences'; + +interface LocalePrefs { + language: string; + timezone: string; + dateFormat: string; + currency: string; +} + +function load(): LocalePrefs { + try { + const raw = localStorage.getItem(STORAGE_KEY); + if (raw) return JSON.parse(raw); + } catch {} + return { language: 'ro', timezone: 'Europe/Bucharest', dateFormat: 'dd.MM.yyyy', currency: 'RON' }; +} + +export default function LocalePage() { + const [prefs, setPrefs] = useState(load); + const [saved, setSaved] = useState(false); + + const update = (key: keyof LocalePrefs, value: string) => { + setPrefs((p) => ({ ...p, [key]: value })); + setSaved(false); + }; + + const save = () => { + try { + localStorage.setItem(STORAGE_KEY, JSON.stringify(prefs)); + setSaved(true); + setTimeout(() => setSaved(false), 2000); + } catch {} + }; + + const now = new Date(); + const tzDisplay = (() => { + try { return now.toLocaleTimeString('ro-RO', { timeZone: prefs.timezone, hour: '2-digit', minute: '2-digit', timeZoneName: 'short' }); } + catch { return '—'; } + })(); + + return ( +
+
+

Limbă & Fus Orar

+

+ Preferințele de localizare sunt salvate local în browser. +

+
+ +
+ {/* Language */} +
+

Limbă Interfață

+
+ {LANGUAGES.map(({ code, label, flag }) => ( + + ))} +
+ {prefs.language !== 'ro' && ( +

+ ⚠ Interfața CEO OS este disponibilă momentan doar în Română. Traducerile vor fi adăugate în versiunile viitoare. +

+ )} +
+ + {/* Timezone */} +
+
+

Fus Orar

+ {tzDisplay} +
+ +
+ + {/* Date format */} +
+

Format Dată

+
+ {DATE_FORMATS.map(({ value, label }) => ( + + ))} +
+
+ + {/* Default currency */} +
+

Monedă Implicită

+ +
+ + +
+
+ ); +}