{% extends 'base.html.twig' %}
{% block title %}Les trésors de Luna{% endblock %}
{% block javascripts %}
<script type="module" src="{{asset('js/buying.js')}}"></script>
<script type="module" src="{{asset('js/classes/Cart.js')}}"></script>
{% endblock javascripts %}
{% block body %}
<body>
<section id="banner" class="py-3" style="background: #F9F3EC;">
<div class="container">
<div class="hero-content py-5 my-3">
<h2 class="display-1 mt-3 mb-0">Détail du <span class="text-primary">Produit:</span></h2>
<nav class="breadcrumb">
<a class="breadcrumb-item nav-link" href="{{path('app_home')}}">Accueil</a>
{% set search = path('search_products') %}
{% if search in comeFromPage %}
<a class="breadcrumb-item nav-link" href="javascript:history.back()">Revenir aux résultats</a>
{% endif %}
<span class="breadcrumb-item active" aria-current="page">{{product.name}}</span>
</nav>
</div>
</div>
</section>
<section id="selling-product">
<div class="container my-md-5 py-5">
<div class="row g-md-5">
<div class="col-lg-6">
<div class="row">
<div class="col-md-12">
<!-- product-large-slider -->
<div class="swiper product-large-slider">
<div class="swiper-wrapper">
<div class="swiper-slide">
<img src="{{asset('uploads/product_images/' ~ product.mainImageLink)}}" class="img-fluid" />
</div>
<div class="swiper-slide">
<img src="{{asset('uploads/product_images/' ~ product.Image0Link)}}" class="img-fluid" />
</div>
<div class="swiper-slide">
<img src="{{asset('uploads/product_images/' ~ product.Image1Link)}}" class="img-fluid" />
</div>
<div class="swiper-slide">
<img src="{{asset('uploads/product_images/' ~ product.Image2Link)}}" class="img-fluid" />
</div>
</div>
</div>
</div>
<div class="col-md-12 mt-2">
<!-- product-thumbnail-slider -->
<div thumbsSlider="" class="swiper product-thumbnail-slider">
<div class="swiper-wrapper">
<div class="swiper-slide" style="cursor: pointer;">
<img src="{{asset('uploads/product_images/' ~ product.mainImageLink)}}" class="img-fluid" />
</div>
{% if product.image0Link %}
<div style="cursor: pointer;" class="swiper-slide">
<img src="{{asset('uploads/product_images/' ~ product.image0Link)}}" class="img-fluid" />
</div>
{% endif %}
{% if product.image1Link %}
<div class="swiper-slide">
<img src="{{asset('uploads/product_images/' ~ product.image1Link)}}" class="img-fluid" />
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6 mt-5 ">
<div class="product-info">
<div class="element-header">
<h2 id="product-name" itemprop="name" class="display-6">{{product.name}}</h2>
</div>
<div class="product-price pt-3 pb-3">
<strong id="product-price" data-price="{{product.price}}" class="text-primary display-6 fw-bold">{{product.price}}€</strong>
</div>
<p id="short-description">{{product.shortDescription|nl2br}}</p>
<div>
<span style="font-weight: bold; margin-right: 5px;">Categorie: </span>{{product.category.name}}
</div>
<div>
{% if product.stock >= 10 %}
<span style="font-weight: bold; margin-right: 5px;">Stock disponible: </span> <span class="stock-indicator" style="font-weight: bold; font-size: 1.2rem; color: yellowgreen">{{product.stock}}</span><br>
{% endif %}
{% if product.stock < 10 and product.stock >= 5 %}
<span style="font-weight: bold; margin-right: 5px">Stock disponible: </span> <span class="stock-indicator" style="font-weight: bold; font-size: 1.2rem; color: orange">{{product.stock}}</span><br>
{% endif %}
{% if product.stock < 5 %}
<span style="font-weight: bold; margin-right: 5px">Stock disponible: </span> <span class="stock-indicator" style="font-weight: bold; font-size: 1.2rem; color: lightcoral">{{product.stock}}</span><br>
{% endif %}
<span style="font-weight: bold;">Poids: </span>{{product.weight}}g <br>
{% if product.customizable %}
<label for="custom-message">Message personnalisé:</label>
<input id="custom-message" name="custom-message" type="text" maxlength="200" placeholder="Votre message (200 caractères max.)" required> <br>
<div id="error-message" style="color:red; font-size:0.9em; margin-bottom:0.5em;"></div>
<label for="custom-police">Style du texte:</label>
<input type="number" id="custom-police" name="custom-police" value="1" min="1" max="10" placeholder="Indiquez le numéro du style de texte" required> <br>
<div id="error-police" style="color:red; font-size:0.9em; margin-bottom:0.5em;"></div>
<label for="custom-image">Motifs : </label>
<input type="number" id="custom-image" name="custom-image" value="1" min="1" max="5" placeholder="Indiquez le numéro du motif" required> <br>
<input type="hidden" id="customizable-product" value="{{product.customizable}}">
<div id="error-image" style="color:red; font-size:0.9em; margin-bottom:0.5em;"></div>
{% endif %}
</div>
<div class="cart-wrap">
<div class="product-quantity pt-2">
<div class="stock-button-wrap">
{% if product.stock != 0 %}
<div style="display:flex; height: 30px;">
<p style="width: 130px; margin:unset; padding: unset;">Quantité: </p>
<div id="quantity-selector" class="input-group product-qty align-items-center w-25">
<span class="input-group-btn">
<button type="button" class="quantity-left-minus btn btn-light btn-number" data-type="minus">
<svg width="16" height="16">
<use xlink:href="#minus"></use>
</svg>
</button>
</span>
<input type="text" id="quantity" data-product-id="{{product.id}}" data-max-quantity="{{stock}}" name="quantity"
class="form-control input-number text-center p-2 mx-1" value="1">
<span class="input-group-btn">
<button type="button" class="quantity-right-plus btn btn-light btn-number" data-type="plus"
data-field="">
<svg width="16" height="16">
<use xlink:href="#plus"></use>
</svg>
</button>
</span>
</div>
</div>
<div class="d-flex flex-wrap pt-4" >
<a href="{{path('add_to_cart', {'id': product.id})}}" data-max-quantity="{{stock}}" class="btn-cart btn-cart-buy me-3 px-4 pt-3 pb-3">
<h5 class="text-uppercase m-0">Ajouter au panier</h5>
</a>
</div>
{% else %}
<p class="alert-stock">Produit indisponible</p>
{% endif %}
</div>
</div>
</div>
<div class="meta-product pt-4">
</div>
</div>
</div>
</div>
</div>
</section>
{% if not product.additionalInformation and product.longDescription %}
<section class="product-info-tabs py-md-5">
<div class="container">
<div class="row">
<div class="d-flex flex-column flex-md-row align-items-start gap-5">
<div class="nav flex-row flex-wrap flex-md-column nav-pills me-3 col-lg-3" id="v-pills-tab" role="tablist"
aria-orientation="vertical">
{% if product.longDescription %}
<button class="nav-link fs-5 mb-2 text-start active" id="v-pills-description-tab" data-bs-toggle="pill"
data-bs-target="#v-pills-description" type="button" role="tab" aria-controls="v-pills-description"
aria-selected="false" tabindex="-1">Description</button>
{% endif %}
{% if product.additionalInformation|nl2br %}
<button class="nav-link fs-5 mb-2 text-start" id="v-pills-additional-tab" data-bs-toggle="pill"
data-bs-target="#v-pills-additional" type="button" role="tab" aria-controls="v-pills-additional"
aria-selected="false" tabindex="-1">Information additionnelle</button>
{% endif %}
{#
<button class="nav-link fs-5 mb-2 text-start" id="v-pills-reviews-tab" data-bs-toggle="pill"
data-bs-target="#v-pills-reviews" type="button" role="tab" aria-controls="v-pills-reviews"
aria-selected="true">Customer Reviews</button>
#}
</div>
{% if product.longDescription %}
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade active show" id="v-pills-description" role="tabpanel"
aria-labelledby="v-pills-description-tab" tabindex="0">
<h2>Description du Produit</h2>
<p>{{product.longDescription|nl2br}}</p>
</div>
{% endif %}
{% if product.additionalInformation %}
<div class="tab-pane fade" id="v-pills-additional" role="tabpanel" aria-labelledby="v-pills-additional-tab"
tabindex="0">
<h2>Information additionnelle</h2>
<p>{{product.additionalInformation|nl2br}}</p>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</section>
{% endif %}
<div class="instagram-wrapper">
{{instagramLinks[0]["link0"]|raw}}
{{instagramLinks[1]["link1"]|raw}}
{{instagramLinks[2]["link2"]|raw}}
{{instagramLinks[3]["link3"]|raw}}
{{instagramLinks[4]["link4"]|raw}}
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const input = document.getElementById('custom-message');
const maxLength = parseInt(input.getAttribute('maxlength'), 10);
// Élément pour le compteur
const counter = document.createElement('div');
counter.style.fontSize = '0.9em';
counter.style.color = '#555';
counter.style.marginTop = '5px';
// Élément pour les erreurs
const feedback = document.createElement('div');
feedback.style.color = 'red';
feedback.style.marginTop = '2px';
input.insertAdjacentElement('afterend', counter);
counter.insertAdjacentElement('afterend', feedback);
updateDisplay();
input.addEventListener('input', updateDisplay);
function updateDisplay() {
const currentLength = input.value.length;
counter.textContent = `${currentLength} / ${maxLength} caractères`;
if (currentLength > maxLength) {
feedback.textContent = `⚠️ Le message dépasse la limite de ${maxLength} caractères.`;
} else {
feedback.textContent = '';
}
}
});
</script>
</body>
<script async src="//www.instagram.com/embed.js"></script>
{% endblock body %}