<template>
  <div class="card">
    <h4 class="card-custom-title">
      {{ $t(i18nConst.lotteryHistoryTicketsTitle) }}
    </h4>
    <!-- <p class="card-custom-info">
      {{ $t(i18nConst.lotteryHistoryTicketsMessage) }}
    </p> -->
    <hr />
    <div class="col-md-12">
      <div v-if="ticketsReversed.length > 0">
        <div v-for="ticket in ticketsReversed" :key="ticket.id" class="row mb-2">
          <div class="col-2 text-center d-flex align-items-center justify-content-center">
            #{{ ticket.id }}
          </div>
          <div class="col-10 d-flex align-items-center justify-content-around">
            <!-- <span style="background-color: #85289b;" class="badge rounded-pill fs-4 text-white">{{
                ticket.numbers.num1
            }}</span> -->
            <span style="background-color: #3F43CD;" class="badge rounded-pill fs-4 text-white">{{
                ticket.numbers.num2
            }}</span>
            <span style="background-color: #e0e4f4;" class="badge rounded-pill fs-4 text-dark">{{
                ticket.numbers.num3
            }}</span>
            <span style="background-color: #C99ED3;" class="badge rounded-pill fs-4 text-dark">{{
                ticket.numbers.num4
            }}</span>
            <span class="badge bg-info rounded-pill fs-4 text-dark">{{
                ticket.numbers.num5
            }}</span>
            <span class="badge bg-dark rounded-pill fs-4 text-dark text-white">{{
                ticket.numbers.num6
            }}</span>
            <span style="background-color: #f0f4fc;" class="badge rounded-pill fs-4 text-dark">{{
                ticket.numbers.num7
            }}</span>
          </div>
        </div>
      </div>
      <div v-else class="empty-card">
        <img src="../../assets/lottery_notickets.png" class="img-fluid w-50 mt-2" alt="Responsive image">
        <p class="empty-card-title">
          {{ $t(i18nConst.lotteryHistoryEmptyTitle) }}
        </p>
        <p class="empty-card-description">
          <!-- {{ $t(i18nConst.lotteryHistoryEmptyDescription) }} -->
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import i18nConstantes from '@/constantes/i18n.constantes.js';
import { mapGetters } from 'vuex';
import typeActions from '@/store/typeActions';

export default {
  data() {
    return {
      i18nConst: i18nConstantes,
    };
  },
  computed: {
    ...mapGetters('lottery', ['historyTickets', 'tickets']),
    ticketsReversed() {
      if (this.tickets) {
        return this.tickets.slice().reverse();
      } else {
        return [];
      }
    },
  },
  async mounted() {
    //await this.$store.dispatch(typeActions.initHistory);
    await this.$store.dispatch(typeActions.getMyTickets);
  },
};
</script>

<style scoped>
</style>
