<template>
  <div class="home">
    <div class="console">
      <CardList :tenant="tenant"></CardList>

      <div class="column column2">
        <ActiveUser :tenant="tenant"></ActiveUser>
        <SalesOverview :tenant="tenant"></SalesOverview>
      </div>
    </div>
  </div>
</template>

<script setup name="home">
  import { useUserStore } from '@/stores/modules/user';
  import { reactive, ref } from 'vue';
  import CardList from './components/CardList.vue'
  import ActiveUser from './components/ActiveUser.vue'
  import SalesOverview from './components/SalesOverview.vue'
  const isAdmin = ref(true);
  const tenant = ref(null);
  const userStore = useUserStore();
  let tenants = '';
  if (userStore.userInfo?.tenants && userStore.userInfo?.tenants.length > 0) {
    if (userStore.userInfo?.tenants.length < 2) {
      tenants = userStore.userInfo?.tenants[0]
    } else {
      tenants = userStore.tenant
    }
  }
  if (userStore.userInfo?.roles && userStore.userInfo?.roles.find(i => i.roleCode === 'tenantAdmin')) {
    tenant.value = tenants.id
  }
  console.log('userStore', userStore.userInfo, userStore.tenant)
</script>

<style scoped lang="scss">
  @use './index.scss';
</style>