paxton-front/components/ProductDescription.vue
alsaze 2e01f58e67
Some checks failed
Deploy / build (push) Has been cancelled
refactoring
2025-11-21 12:48:00 +03:00

126 lines
3.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="product-description">
<h1>{{ productsData?.name }}</h1>
<ProductPrice :price="currentVariant?.options[0]?.price" />
<ProductVariations v-if="colors?.length > 1" />
<div>
{{ `Цвет: ${t(`colors.${currentColor}`)}` }}
</div>
<div>
{{ `Материал: ${t(`materials.${currentMaterial}`)}` }}
</div>
<div>
Размер
</div>
<div class="product-description__sizes">
<div
v-for="option in currentVariant?.options"
:key="option"
class="product-description__size"
@click="() => currentSize = option"
>
<UButton
block
:label="getAttribute(option?.attributes, 'size')?.option"
:disabled="option?.stock_status === 'outofstock'"
:variant="currentSize === option ? undefined : 'outline'"
/>
</div>
</div>
<UButton
:disabled="!currentSize"
class="justify-content-center"
:label="currentSize ? `Добавить в корзину` : `Выберите размер`"
size="xl"
@click="addToCartBtn()"
/>
<UAccordion :items="items" />
</div>
</template>
<script setup lang="ts">
import ProductPrice from '~/components/ProductPrice.vue'
import ProductVariations from '~/components/ProductVariations.vue'
import { useCurrentProduct, useProduct } from '~/composables'
const { t } = useI18n()
const { cartAddItem } = useCart()
const { productsData, colors, getAttribute } = useProduct()
const { currentVariant, currentColor, currentMaterial } = useCurrentProduct()
const currentSize = ref(undefined)
const items = computed(() => [
{
label: 'Описание товара',
icon: 'i-heroicons-document-text',
content: productsData?.value?.description?.replace(/<\/?p>/g, ''),
},
{
label: 'Состав и параметры',
icon: 'i-heroicons-beaker',
content: 'хлопок 100%',
},
{
label: 'Рекомендации по уходу',
icon: 'i-heroicons-sparkles',
content: 'Бережная стирка при максимальной температуре 30ºС\nНе отбеливать\nМашинная сушка запрещена\nГлажение при 110ºС\nПрофессиональная сухая чистка',
},
{
label: 'Доставка и оплата',
icon: 'i-heroicons-truck',
content: 'Доставка в пункт выдачи',
},
{
label: 'Возврат и обмен',
icon: 'i-heroicons-arrow-path',
content: 'Возврат в течение 14 дней\nОбмен размера в течение 7 дней',
},
])
function addToCartBtn() {
cartAddItem({ variation_id: currentSize?.value?.id })
}
</script>
<style lang="scss">
.product-description {
width: 100%;
padding: 30px 30px 0;
display: flex;
flex-direction: column;
gap: 10px;
@media (min-width: 768px) {
position: sticky;
top: 40px;
max-height: calc(100vh - 40px);
max-width: 350px;
overflow-y: auto;
}
@include mobile {
padding: 20px 30px;
}
&__sizes {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 4px;
}
&__size {
width: 65px;
}
}
</style>