import { defineComponent, ref, onMounted } from 'vue'

import { CImgText } from '../../../components/CImgText/index'
import { CCard } from '@src/components/CCard'
import { CMyPage } from '@src/components/CMyPage'
import { CTitleBanner } from '@src/components/CTitleBanner'
import { CGridTableRec } from '@src/components/CGridTableRec'
import { CMyFieldRec } from '@src/components/CMyFieldRec'
import { CMyFieldDb } from '@src/components/CMyFieldDb'

import { useGlobalStore } from '@store/globalStore'
import { costanti } from '@costanti'
import { tools } from '@src/store/Modules/tools'

import { colTableProducer } from '@src/store/Modules/fieldsTable'
import MixinMetaTags from '@src/mixins/mixin-metatags'

export default defineComponent({
  name: 'settings',
  components: { CImgText, CCard, CMyPage, CTitleBanner, CGridTableRec, CMyFieldRec, CMyFieldDb },
  setup() {

    const mysite = ref(<any>null)
    const tab = ref('server')

    const globalStore = useGlobalStore()

    const { setmeta } = MixinMetaTags()

    async function mounted() {
      mysite.value = await globalStore.caricaTabella('sites', tools.getEnv('VITE_APP_ID')!)
    }

    function save(newval: any) {
      console.log('ConfSite save')
      tools.updateFonts(newval)
    }

    onMounted(mounted)

    return {
      setmeta,
      mysite,
      costanti,
      tab,
      tools,
      save,
      globalStore,
    }
  }
})
