<template>
  <q-option-group
    class="q-ma-xs"
    style="text-align: left !important"
    v-model="searchType"
    :options="options"
    color="primary"
  />
  <q-tab-panels v-model="searchType" keep-alive animated class="shadow-2 rounded-borders">
    <q-tab-panel name="username">
      <CGridTableRec
        prop_mytable="users"
        prop_mytitle=""
        subtitle=""
        :prop_mycolumns="colmyUserPeople"
        prop_colkey="_id"
        col_title="username"
        :vertical="costanti.VISUTABLE_LISTA"
        nodataLabel=" "
        :prop_search="true"
        :prop_showfilter="true"
        hint="Cerca il nome o Username"
        :hintinbtnsearch="true"
        :findByDebounce="true"
        :showSearchOnTop="false"
        :finder="true"
        :choose_visutype="false"
        :finder_noNull="false"
        :finder_noNullFilters="true"
        :options="shared_consts.OPTIONS_SEARCH_USER_ALL_WORDS"
        :butt_modif_new="false"
        noresultLabel="Username, Nome o Cognome non trovato"
        :arrfilters="arrfilterand"
        :filtercustom="filtercustom"
        :prop_searchList="searchList"
        :showType="costanti.SHOW_USERINFO"
        :showCol="false"
        :extraparams="extraparams()"
        :actionType="actionType"
      >
      </CGridTableRec>
    </q-tab-panel>
    <q-tab-panel name="receivers">
      <div class="column centeritems">
        <q-btn-toggle
          v-if="arrTypesAccounts.length > 0"
          v-model="tipoConto"
          class="my-custom-toggle"
          no-caps
          rounded
          unelevated
          toggle-color="primary"
          color="white"
          text-color="primary"
          :options="arrTypesAccounts"
        />

        <div v-if="tipoConto === shared_consts.AccountType.USER">
          <div v-for="(rec, i) in usersList.list" :key="i">
            <div class="q-pa-xs q-ma-xs q-border q-rounded my-custom-border">
              <CMyUser
                :mycontact="rec"
                :visu="costanti.FIND_PEOPLE"
                @setCmd="tools.setCmd"
                :actionType="actionType"
              >
              </CMyUser>
              <CContactUser
                :myuser="rec"
                :showBtnActivities="false"
                :sendRIS="tools.isUserOk() ? sendRIS : false"
                :actionType="actionType"
              />
            </div>
          </div>
        </div>
        <div
          v-else-if="tipoConto === shared_consts.AccountType.CONTO_DI_GRUPPO"
        >
          <div v-for="(grp, i) in usersList.listgroup" :key="i">
            <CMyGroup :mygrp="grp" :visu="costanti.USER_GROUPS" :noaut="true">
            </CMyGroup>
          </div>
        </div>
      </div>
      <div class="column">&nbsp;</div>
      <br />
      <div class="row centeritems justify-evenly items-center">
        <q-btn
          icon="autorenew"
          rounded
          glossy
          dense
          color="primary"
          :label="$t('dialog.update_receivers')"
          :disable="loading"
          @click="updateUserListRIS()"
        >
        </q-btn>

        <q-spinner-radio v-if="loading" class="q-ma-sm" color="brown" />
        <div class="q-ma-sm">&nbsp;</div>
        <br>
      </div>
    </q-tab-panel>
    <q-tab-panel name="qrcode">
      <CQRCode :read="true"></CQRCode>
    </q-tab-panel>
  </q-tab-panels>
</template>

<script lang="ts" src="./CFindUsers.ts">
</script>

<style lang="scss" scoped>
@import './CFindUsers.scss';
</style>
