```
✨ feat(ReserverController): Modifie la route de création de session. 🐛 fix(ErrorListener): Corrige l'envoi de mails d'erreur en prod. ♻️ refactor(FlowReserve): Simplifie la validation du panier de réservation. ✅ test(ErrorListener): Ajoute des tests pour la gestion des erreurs. ```
This commit is contained in:
@@ -94,15 +94,15 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
|
||||
ensureSidebarExists() {
|
||||
if (document.getElementById(this.sidebarId)) return;
|
||||
|
||||
|
||||
const template = `
|
||||
<div id="${this.sidebarId}" class="fixed inset-0 z-[100] flex justify-end pointer-events-none">
|
||||
<!-- Backdrop -->
|
||||
<div class="backdrop absolute inset-0 bg-slate-900/60 backdrop-blur-sm opacity-0 transition-opacity duration-300"></div>
|
||||
|
||||
|
||||
<!-- Panel -->
|
||||
<div class="panel w-full max-w-md bg-white shadow-2xl translate-x-full transition-transform duration-300 flex flex-col relative z-10">
|
||||
|
||||
|
||||
<!-- Header -->
|
||||
<div class="p-6 border-b border-gray-100 flex items-center justify-between bg-white">
|
||||
<div>
|
||||
@@ -112,12 +112,12 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
<svg class="w-6 h-6 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Content (Loader/List/Empty) -->
|
||||
<div id="flow-reserve-content" class="flex-1 overflow-y-auto p-6 space-y-6 bg-gray-50/50 relative">
|
||||
<!-- Content injected via JS -->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Footer -->
|
||||
<div id="flow-reserve-footer" class="p-6 border-t border-gray-100 bg-white">
|
||||
<!-- Content injected via JS -->
|
||||
@@ -126,10 +126,10 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
</div>
|
||||
`;
|
||||
document.body.insertAdjacentHTML('beforeend', template);
|
||||
|
||||
|
||||
// Bind events
|
||||
const sidebar = document.getElementById(this.sidebarId);
|
||||
|
||||
|
||||
const closeHandler = (e) => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
@@ -154,7 +154,7 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
footer.innerHTML = '';
|
||||
|
||||
const ids = this.getList();
|
||||
|
||||
|
||||
// Retrieve dates from localStorage
|
||||
let dates = { start: null, end: null };
|
||||
try {
|
||||
@@ -172,7 +172,7 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
const response = await fetch(this.apiUrl, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
body: JSON.stringify({
|
||||
ids,
|
||||
start: dates.start,
|
||||
end: dates.end
|
||||
@@ -182,12 +182,12 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
if (!response.ok) throw new Error('Erreur réseau');
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
|
||||
// Merge client-side dates if server didn't return them (or to prioritize client choice)
|
||||
if (!data.start_date && dates.start) data.start_date = this.formatDate(dates.start);
|
||||
if (!data.end_date && dates.end) data.end_date = this.formatDate(dates.end);
|
||||
|
||||
// Fallback: if server returns dates in a format we can use directly, fine.
|
||||
|
||||
// Fallback: if server returns dates in a format we can use directly, fine.
|
||||
// If we just want to display what is in local storage:
|
||||
if (dates.start) data.start_date = this.formatDate(dates.start);
|
||||
if (dates.end) data.end_date = this.formatDate(dates.end);
|
||||
@@ -291,7 +291,7 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
<span class="text-[#f39e36]">${this.formatPrice(total.totalTTC || total.totalHT)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/reservation/devis" id="flow-validate-btn" class="block w-full py-4 bg-slate-900 text-white text-center rounded-2xl font-black uppercase italic tracking-widest hover:bg-[#fc0e50] transition-colors shadow-lg">
|
||||
<a data-turbo="false" href="/reservation/devis" id="flow-validate-btn" class="block w-full py-4 bg-slate-900 text-white text-center rounded-2xl font-black uppercase italic tracking-widest hover:bg-[#fc0e50] transition-colors shadow-lg">
|
||||
Valider ma demande
|
||||
</a>
|
||||
`;
|
||||
@@ -306,7 +306,7 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
|
||||
async validateBasket(e) {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
const ids = this.getList();
|
||||
let dates = { start: null, end: null };
|
||||
try {
|
||||
@@ -316,10 +316,10 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/reservation/session', {
|
||||
const response = await fetch('/session', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
body: JSON.stringify({
|
||||
ids,
|
||||
start: dates.start,
|
||||
end: dates.end
|
||||
|
||||
Reference in New Issue
Block a user