<template>
  <div id="dashboard" v-if="authUser.username">
    <div class="container">
      <UserStatsCards :user="authUser" />
    </div>
    <div class="container dashboard-container">
      <div class="left-container dashboard-sub-container">
        <UserMonthStats :user="authUser" />
        <UserRecords :user="authUser" />
      </div>
      <div class="right-container dashboard-sub-container">
        <UserCalendar :user="authUser" />
        <Timeline :user="authUser" />
      </div>
    </div>
  </div>
</template>

<script lang="ts">
  import { computed, ComputedRef, defineComponent } from 'vue'

  import Timeline from '@/components/Dashboard/Timeline/index.vue'
  import UserCalendar from '@/components/Dashboard/UserCalendar/index.vue'
  import UserMonthStats from '@/components/Dashboard/UserMonthStats.vue'
  import UserRecords from '@/components/Dashboard/UserRecords/index.vue'
  import UserStatsCards from '@/components/Dashboard/UserStartsCards/index.vue'
  import { USER_STORE } from '@/store/constants'
  import { IAuthUserProfile } from '@/types/user'
  import { useStore } from '@/use/useStore'

  export default defineComponent({
    name: 'Dashboard',
    components: {
      Timeline,
      UserCalendar,
      UserMonthStats,
      UserRecords,
      UserStatsCards,
    },
    setup() {
      const store = useStore()
      const authUser: ComputedRef<IAuthUserProfile> = computed(
        () => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
      )
      return { authUser }
    },
  })
</script>

<style lang="scss" scoped>
  @import '~@/scss/base';
  .dashboard-container {
    display: flex;
    flex-direction: row;
    padding-bottom: 30px;
    .dashboard-sub-container {
      display: flex;
      flex-direction: column;
    }
    .left-container {
      width: 32%;
    }
    .right-container {
      width: 68%;
    }
  }
  @media screen and (max-width: $small-limit) {
    .dashboard-container {
      display: flex;
      flex-direction: column;
      .left-container {
        width: 100%;
      }
      .right-container {
        width: 100%;
      }
    }
  }
</style>
