Refactor routes to use cleaner URL structure with order_id parameter

This commit is contained in:
kbe
2025-09-06 03:12:11 +02:00
parent 01b545c83e
commit d9d43f45e5
11 changed files with 75 additions and 101 deletions

View File

@@ -10,12 +10,17 @@ export default class extends Controller {
"checkoutButton",
"form",
];
static values = { eventSlug: String, eventId: String };
static values = { targetUrl: String, eventSlug: String, eventId: String };
// Initialize the controller and update the cart summary
connect() {
console.log("TicketSelectionController connected");
console.log("Target URL: ", this.target);
this.updateCartSummary();
this.bindFormSubmission();
}
// Bind form submission to handle cart storage
@@ -118,8 +123,9 @@ export default class extends Controller {
await this.storeCartInSession(cartData);
// Redirect to event-scoped orders/new page
const OrderNewUrl = `/events/${this.eventSlugValue}.${this.eventIdValue}/orders/new`;
window.location.href = OrderNewUrl;
// const orderNewUrl = `/orders/new/events/${this.eventSlugValue}.${this.eventIdValue}`;
const orderNewUrl = `/orders/new/events/${this.eventSlugValue}.${this.eventIdValue}`;
window.location.href = orderNewUrl;
} catch (error) {
console.error("Error storing cart:", error);
alert("Une erreur est survenue. Veuillez réessayer.");