Files
aperonight/app/javascript/controllers/flash_message_controller.js
kbe 48547f3aad feat: Implement complete ticket purchasing flow with new TicketsController │
│
- Create new TicketsController with actions for name collection, creation, and checkout                                                                                                                                                                   │
- Add dedicated ticket views (new.html.erb, checkout.html.erb, show.html.erb)                                                                                                                                                                             │
- Update ticket_selection_controller.js to handle form submission via AJAX                                                                                                                                                                                │
- Add store_cart endpoint in EventsController for session-based cart management                                                                                                                                                                           │
- Update routes to support new ticket flow: /tickets/new, /create, /checkout                                                                                                                                                                              │
- Fix attribute name consistency across views (title→name, starts_at→start_time)                                                                                                                                                                          │
- Add Stripe checkout integration with proper error handling                                                                                                                                                                                              │
- Remove deprecated collect_names flow in favor of streamlined approach                                                                                                                                                                                   │
                                                                                                                                                                                                                                                          │
The flow is now: Event selection → AJAX cart storage → Name collection → Checkout → Payment
2025-08-30 20:01:59 +02:00

42 lines
1.1 KiB
JavaScript
Executable File

import { Controller } from "@hotwired/stimulus"
// Controller for handling flash messages
// Automatically dismisses messages after a timeout and handles manual closing
export default class extends Controller {
// Define targets for the controller
static targets = ["message"]
// Initialize the controller when it connects to the DOM
connect() {
console.log("FlashMessageController mounted", this.element);
// Initialize Lucide icons for this element if available
if (typeof lucide !== 'undefined') {
lucide.createIcons({ within: this.element });
}
// Auto-dismiss after 2 seconds
this.timeout = setTimeout(() => {
this.close()
}, 5000)
}
// Clean up the timeout when the controller disconnects
disconnect() {
if (this.timeout) {
clearTimeout(this.timeout)
}
}
// Close the flash message with a fade-out animation
close() {
// Add opacity transition classes
this.element.classList.add('opacity-0', 'transition-opacity', 'duration-300')
// Remove element after transition completes
setTimeout(() => {
this.element.remove()
}, 300)
}
}