<template>
  <div class="preview-days-item">
    <div class="preview-days-item__text">{{ weekName }}</div>
    <q-btn
      v-on="$listeners"
      v-bind="$attrs"
      :color="isCurrentDate ? 'secondary' : undefined"
      :class="{ 'bg-secondary text-white': isCurrentDate }"
      size="md"
      dense
      flat
      round
      style="border-radius: 8px;"
    >
      {{ targetDate.getDate() }}
    </q-btn>
  </div>
</template>

<style scoped lang="sass">
.preview-days-item
  text-align: center

.preview-days-item__text
  color: $blue-grey
  font-size: 12px
  text-transform: lowercase
  margin-bottom: 4px
</style>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { date, QBtn } from 'quasar'

const weekNames = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']

@Component({
  inheritAttrs: false,
  components: { QBtn },
})
export default class PreviewDaysPickerItem extends Vue {
  @Prop(Date)
  currentDate!: Date

  @Prop(Date)
  targetDate!: Date

  get isCurrentDate() {
    return date.isSameDate(this.currentDate, this.targetDate)
  }

  get weekName() {
    return weekNames[date.getDayOfWeek(this.targetDate) - 1]
  }
}
</script>
