```
✨ feat(revervation): [Ajoute la création de session de réservation et le flow] 🐛 fix(PurgeCommandTest): [Utilise addCommand au lieu de add pour les commandes] 📝 chore(deps): [Mise à jour des dépendances Composer et corrections] 🐛 fix(KeycloakAuthenticator): [Corrige le type nullable de l'exception start] ✨ feat(Customer): [Ajoute les sessions de commandes aux entités Customer] ♻️ refactor(AppLogger): [Refactorise l'AppLogger pour obtenir l'UserAgent] ✨ feat(FlowReserve): [Ajoute une action de validation du panier] ```
This commit is contained in:
@@ -291,10 +291,50 @@ export class FlowReserve extends HTMLAnchorElement {
|
||||
<span class="text-[#f39e36]">${this.formatPrice(total.totalTTC || total.totalHT)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/reservation/devis" 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 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>
|
||||
`;
|
||||
|
||||
const validateBtn = footer.querySelector('#flow-validate-btn');
|
||||
if (validateBtn) {
|
||||
validateBtn.addEventListener('click', (e) => {
|
||||
this.validateBasket(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async validateBasket(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const ids = this.getList();
|
||||
let dates = { start: null, end: null };
|
||||
try {
|
||||
dates = JSON.parse(localStorage.getItem('reservation_dates') || '{}');
|
||||
} catch (error) {
|
||||
console.warn('Invalid reservation dates in localStorage');
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/reservation/session', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
ids,
|
||||
start: dates.start,
|
||||
end: dates.end
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('Erreur réseau');
|
||||
|
||||
const data = await response.json();
|
||||
if (data.flowUrl) {
|
||||
window.location.href = data.flowUrl;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la validation du panier', error);
|
||||
}
|
||||
}
|
||||
|
||||
formatDate(dateString) {
|
||||
|
||||
Reference in New Issue
Block a user