<template>
  <div class="cart">
    <div class="container">
      <div class="cart__wrapper">
        <div class="cart__top">
          <h1 class="cart__top-title">{{ t('cart.title') }}</h1>
          <p>({{ t('cart.items', productsInCartQuantity, { count: productsInCartQuantity }) }})</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import {usePageTitle} from "@composables/utils";

const {t} = useI18n();
const cartStore = useCartStore();

const productsInCart = computed(() => {
  return cartStore.currentOrder ? cartStore.currentOrder.orderProducts.edges : [];
});
const totalPrice = computed(() => {
  return cartStore.currentOrder ? cartStore.currentOrder.totalPrice : 0;
});
const productsInCartQuantity = computed(() => {
  let count = 0;
  cartStore.currentOrder?.orderProducts?.edges.forEach((el) => {
    count = count + el.node.quantity;
  });

  return count;
});

const { setPageTitle } = usePageTitle();

setPageTitle(t('breadcrumbs.cart'));
</script>

<style lang="scss" scoped>
.cart {
  padding-block: 50px 100px;
  background-color: $white;

  &__wrapper {
    display: flex;
    flex-direction: column;
    gap: 32px;
  }

  &__top {
    display: flex;
    align-items: center;
    justify-content: space-between;

    &-title {
      color: #1a1a1a;
      font-family: "Playfair Display", sans-serif;
      font-size: 36px;
      font-weight: 600;
      letter-spacing: -0.5px;
    }

    & p {
      color: #4b5563;
      font-size: 18px;
      font-weight: 400;
      letter-spacing: -0.5px;
    }
  }
}
</style>