import {defineStore} from 'pinia'
import SettingApi from '@/api/SettingApi'
import type Setting from '@/mode/Setting'
import {useUserStore} from '@/store/userStore'

export interface State {
  setting: Setting | undefined
}

export const useSettingStore = defineStore({
  id: 'setting_store',
  state: (): State => ({
    setting: undefined
  }),
  actions: {
    loadData() {
      const userId =  useUserStore().getUser()?.id
      if (userId) {
        SettingApi.get(userId).then((res) => {
          this.setting = res.data
        })
      }
    }
  }
})
