import { CMyGroups } from '@src/components/CMyGroups'
import { CFinder } from '@src/components/CFinder'
import { CGridTableRec } from '@src/components/CGridTableRec'
import { CNotifAtTop } from '@src/components/CNotifAtTop'
import { tools } from '@tools'
import { toolsext } from '@store/Modules/toolsext'
import { computed, defineComponent, onMounted, ref, watch } from 'vue'
import { useUserStore } from '@store/UserStore'
import { useRoute, useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore'
import { CCheckIfIsLogged } from '@src/components/CCheckIfIsLogged'
import { useI18n } from 'vue-i18n'
import { colmyUserGroup } from '@store/Modules/fieldsTable'
import { costanti } from '@costanti'
import { shared_consts } from '@src/common/shared_vuejs'

export default defineComponent({
  name: 'mygroups',
  components: { CMyGroups, CGridTableRec, CNotifAtTop, CFinder, CCheckIfIsLogged },
  props: {},
  setup() {
    const userStore = useUserStore()
    const { t } = useI18n()

    const filter = ref(costanti.FIND_GROUP)

    function mounted() {

      const filt_loaded = tools.getCookie(tools.COOK_SEARCH + tools.GROUP_SEARCH, costanti.FIND_GROUP, true)
      console.log('filt_loaded', filt_loaded)
      filter.value = filt_loaded ? filt_loaded : costanti.FIND_GROUP
    }

    watch(() => filter.value, (newval: any, oldval) => {
      tools.setCookie(tools.COOK_SEARCH + tools.GROUP_SEARCH, newval)

    })
    onMounted(mounted)

    return {
      filter,
      tools,
      costanti,
      shared_consts,
      colmyUserGroup,
      toolsext,
    }
  }
})
