<template>
  <div class="row text-center justify-evenly items-center">
      <CUserInfoAccount
        :user="contact"
        :circuitpath="circuitpath"
        :admin="false"
        :onlysaldo="true"
      />
    <div class="q-mb-sm">
      <q-btn
        icon="fas fa-upload"
        color="primary"
        size="md"
        rounded
        :label="$t('circuit.sendcoins_toso')"
        @click="sendCoinsToClick"
      >
      </q-btn>
      &nbsp;
      <q-btn
        icon="fas fa-download"
        color="primary"
        size="md"
        rounded
        :label="$t('circuit.receive_coins')"
        @click="tools.receiveRis($q, $t)"
      >
      </q-btn>
    </div>
  </div>
  <q-dialog v-model="usersList.show">
    <q-card class="dialog_card">
      <q-toolbar class="bg-primary text-white">
        <q-toolbar-title>
          {{ usersList.title }}
        </q-toolbar-title>
        <q-btn flat round color="white" icon="close" v-close-popup></q-btn>
      </q-toolbar>

      <q-card-section class="inset-shadow">
        <div>{{ $t('circuit.lista_ricev_title') }}</div>

        <div class="row centeritems justify-evenly items-center">
          <q-btn
            icon="fas fa-wifi"
            rounded
            glossy
            color="primary"
            :label="$t('dialog.update')"
            :disable="loading"
            @click="updateUserListRIS()"
          >
          </q-btn>

          <q-spinner-radio v-if="loading" class="q-ma-sm" color="brown" />
        </div>
        <br />

        <div class="row 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 === costanti.AccountType.USER">
            <div v-for="(rec, i) in usersList.list" :key="i">
              <CMyUser
                :mycontact="rec"
                :visu="costanti.FIND_PEOPLE"
                @setCmd="tools.setCmd"
              >
              </CMyUser>
            </div>
          </div>
          <div
            v-else-if="tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT"
          >

            <div v-for="(grp, i) in usersList.listgroup" :key="i">
              <CMyGroup :mygrp="grp" :visu="costanti.USER_GROUPS" :noaut="true">
              </CMyGroup>
            </div>
          </div>
        </div>
      </q-card-section>

      <q-card-actions align="center">
        <q-btn
          rounded
          icon="close"
          v-close-popup
          :label="$t('dialog.close')"
        ></q-btn>
        <q-btn
          rounded
          :label="$t('circuit.vaialcircuito')"
          color="primary"
          :to="tools.updateLink('/circuits')"
        >
        </q-btn>
      </q-card-actions>
    </q-card>
  </q-dialog>
</template>

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

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