import { computed, defineComponent, ref, watch } from 'vue'
import { CSignUp } from '../../../components/CSignUp'
import { useQuasar } from 'quasar'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '@store/UserStore'
import { useRoute } from 'vue-router'
import { tools } from '@tools'

export default defineComponent({
  name: 'SignUpCollettivo',
  components: { CSignUp },
  props: {},
  setup() {
    const $route = useRoute()

    const adult = ref(false)
    const invited = computed(() => $route.params.invited)
    const regexpire = computed(() => $route.params.regexpire)
    const username_default = computed(() => $route.params.username_default)
    const name_default = computed(() => $route.params.name_default)

    // @ts-ignore
    watch(() => invited, (newval, oldval) => {
      console.log('$route.params.invited')
      adult.value = !!$route.params.invited
    })

    function created() {
      if (!tools.getCookie(tools.APORTADOR_SOLIDARIO, '')) {
        // @ts-ignore
        tools.setCookie(tools.APORTADOR_SOLIDARIO, $route.params.invited ? $route.params.invited : '')
      }
    }

    created()

    return {
      regexpire,
      username_default,
      name_default,
    }
  },
})
