import { defineStore } from 'pinia'

export type SupportedLocale = 'zh-CN' | 'en-US' | 'th-TH'

export const useAppPreferencesStore = defineStore('appPreferences', {
  state: () => ({
    locale: 'zh-CN' as SupportedLocale,
    darkMode: false,
  }),
  actions: {
    setLocale(locale: SupportedLocale) {
      this.locale = locale
    },
    toggleTheme() {
      this.darkMode = !this.darkMode
      document.documentElement.classList.toggle('app-theme-dark', this.darkMode)
    },
  },
})
