<template>
  <LayoutContainer>
    <v-row>
      <table>
        <thead>
          <tr>
            <th/>

            <th>
              <p class="standard">Standard</p>
              <p class="from">À partir de</p>
              <p class="price">
                {{ standardPrice }} <span class="ttc">ttc</span>
              </p>
              <p class="month">/mois</p>
            </th>

            <th class="premium-column">
              <p class="standard">Premium</p>
              <p class="from">À partir de</p>
              <p class="price">
                {{ premiumPrice }} <span class="ttc">ttc</span>
              </p>
              <p class="month">/mois</p>
            </th>
          </tr>
        </thead>

        <tbody>
          <tr
            v-for="(item, index) in items"
            :key="item.label"
          >
            <td class="label-column">
              {{ item.label }}
            </td>

            <td>
              <v-icon
                v-if="item.includedInStandard === true"
                icon="far fa-check-circle"
                size="18"
              />

              <v-icon
                v-else-if="item.includedInStandard === false"
                icon="far fa-times-circle"
                size="18"
                color="red"
              />

              <span v-else>
                {{ item.includedInStandard }}
              </span>
            </td>

            <td>
              <v-icon
                v-if="item.includedInPremium === true"
                icon="far fa-check-circle"
                size="18"
              />

              <v-icon
                v-else-if="item.includedInPremium === false"
                icon="far fa-times-circle"
                size="18"
                color="red"
              />

              <span v-else>
                {{ item.includedInPremium }}
              </span>
            </td>
          </tr>
        </tbody>
      </table>
    </v-row>
  </LayoutContainer>
</template>

<script setup lang="ts">

import { ComparisonItem } from "~/types/interface";

const props = defineProps({
  standardPrice: {
    type: String,
    required: true
  },
  premiumPrice: {
    type: String,
    required: true
  },
  items: {
    type: Array as PropType<Array<ComparisonItem>>,
    required: true
  }
});
</script>

<style scoped lang="scss">
.v-row {
  align-items: center;
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
  width: 90%;
}

table {
  width: 70%;
  margin-top: 1rem;
  margin-right: auto;
  margin-left: auto;
  border: none;
  border-collapse: collapse;
}

th {
  height: 8rem;
  font-weight: 400;
  font-size: 30px;
  line-height: 34px;
}

tr {
  height: 3rem;
  text-align: center;
}

tbody tr:nth-child(even) {
  background-color: var(--secondary-color);
}

td {
  padding-right: 5rem;
}

td:first-child {
  text-align: left;
  padding-left: 20px;
  font-weight: 600;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--on-neutral-color-alt);
}

.standard {
  font-weight: 600;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary-color);
  padding-right: 5rem;
  margin-bottom: 1rem;
}

.from,
.ttc {
  font-weight: 300;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
  color: var(--on-neutral-color-alt);
  padding-right: 5rem;
}

.ttc {
  text-transform: uppercase;
}

.price,
.month {
  font-size: 30px;
  line-height: 34px;
  text-align: center;
  color: var(--on-neutral-color-alt);
}

.month {
  padding-right: 5rem;
}
</style>
