Remove unused code and dependencies
- Removed unused JavaScript controllers (shadcn_test, featured_event, event_form, ticket_type_form) - Removed unused React components (button.jsx and utils.js) - Removed duplicate env.example file - Removed unused Alpine.js dependencies from package.json - Updated controller registrations and dependency files - Added REFACTORING_SUMMARY.md with details of changes - Added new file: app/controllers/api/v1/orders_controller.rb
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
import * as React from "react"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { cva } from "class-variance-authority";
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
// Define button styles using class-variance-authority for consistent styling
|
||||
const buttonVariants = cva(
|
||||
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"bg-purple text-purple-foreground shadow-xs hover:bg-purple/90",
|
||||
destructive:
|
||||
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
||||
outline:
|
||||
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
||||
ghost:
|
||||
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
||||
link: "text-purple underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
||||
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
||||
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
||||
icon: "size-9",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Button component that can render as a regular button or as a Slot (for composition)
|
||||
function Button({
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
asChild = false,
|
||||
...props
|
||||
}) {
|
||||
// Use Slot component if asChild is true, otherwise render as a regular button
|
||||
const Comp = asChild ? Slot : "button"
|
||||
|
||||
return (
|
||||
<Comp
|
||||
data-slot="button"
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
{...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export { Button, buttonVariants }
|
||||
@@ -1,28 +0,0 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// Event form controller for handling form interactions
|
||||
// Handles auto-slug generation from event names
|
||||
export default class extends Controller {
|
||||
static targets = ["name", "slug"]
|
||||
|
||||
connect() {
|
||||
console.log("Event form controller connected")
|
||||
}
|
||||
|
||||
// Auto-generate slug from name input
|
||||
generateSlug() {
|
||||
// Only auto-generate if slug field is empty
|
||||
if (this.slugTarget.value === "") {
|
||||
const slug = this.nameTarget.value
|
||||
.toLowerCase()
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "") // Remove accents
|
||||
.replace(/[^a-z0-9\s-]/g, "") // Remove special chars
|
||||
.replace(/\s+/g, "-") // Replace spaces with dashes
|
||||
.replace(/-+/g, "-") // Remove duplicate dashes
|
||||
.replace(/^-|-$/g, "") // Remove leading/trailing dashes
|
||||
|
||||
this.slugTarget.value = slug
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// Controller for handling animations of featured event cards
|
||||
// Uses intersection observer to trigger animations when cards come into view
|
||||
export default class extends Controller {
|
||||
// Define targets for the controller
|
||||
static targets = ["card"]
|
||||
|
||||
// Define CSS classes that can be used with this controller
|
||||
static classes = ["visible"]
|
||||
|
||||
// Define configurable values with defaults
|
||||
static values = {
|
||||
threshold: { type: Number, default: 0.1 }, // Percentage of element visibility needed to trigger animation
|
||||
rootMargin: { type: String, default: '0px 0px -50px 0px' }, // Margin around root element for intersection detection
|
||||
staggerDelay: { type: Number, default: 0.2 } // Delay between card animations in seconds
|
||||
}
|
||||
|
||||
// Initialize the controller when it connects to the DOM
|
||||
connect() {
|
||||
console.log("FeaturedEventController connected")
|
||||
this.setupIntersectionObserver()
|
||||
this.setupStaggeredAnimations()
|
||||
}
|
||||
|
||||
// Clean up observers when the controller disconnects
|
||||
disconnect() {
|
||||
if (this.observer) {
|
||||
this.observer.disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
// Set up intersection observer to detect when cards come into view
|
||||
setupIntersectionObserver() {
|
||||
// Configure observer options
|
||||
const observerOptions = {
|
||||
threshold: this.thresholdValue,
|
||||
rootMargin: this.rootMarginValue
|
||||
}
|
||||
|
||||
// Create intersection observer
|
||||
this.observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
// Add visible class when card comes into view
|
||||
if (entry.isIntersecting) {
|
||||
entry.target.classList.add('visible')
|
||||
}
|
||||
})
|
||||
}, observerOptions)
|
||||
|
||||
// Observe all card elements within this controller's scope
|
||||
const elements = this.cardTargets
|
||||
console.log("Card targets:", elements)
|
||||
elements.forEach(el => {
|
||||
this.observer.observe(el)
|
||||
})
|
||||
}
|
||||
|
||||
// Set up staggered animations for cards with progressive delays
|
||||
setupStaggeredAnimations() {
|
||||
console.log("Setting up staggered animations")
|
||||
console.log("Card targets:", this.cardTargets)
|
||||
// Add staggered animation delays to cards
|
||||
this.cardTargets.forEach((card, index) => {
|
||||
card.style.transitionDelay = `${index * this.staggerDelayValue}s`
|
||||
card.classList.remove('visible')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Old code
|
||||
<script>
|
||||
// Add animation classes when elements are in view
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const observerOptions = {
|
||||
threshold: 0.1,
|
||||
rootMargin: '0px 0px -50px 0px'
|
||||
};
|
||||
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
entry.target.classList.add('visible');
|
||||
}
|
||||
});
|
||||
}, observerOptions);
|
||||
|
||||
// Observe animated elements
|
||||
document.querySelectorAll('.animate-fadeInUp, .animate-slideInLeft, .animate-slideInRight').forEach(el => {
|
||||
observer.observe(el);
|
||||
});
|
||||
|
||||
// Add staggered animation delays
|
||||
document.querySelectorAll('.featured-event-card').forEach((card, index) => {
|
||||
card.style.transitionDelay = `${index * 0.2}s`;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
*/
|
||||
@@ -18,9 +18,3 @@ application.register("ticket-selection", TicketSelectionController);
|
||||
|
||||
import HeaderController from "./header_controller";
|
||||
application.register("header", HeaderController);
|
||||
|
||||
import EventFormController from "./event_form_controller";
|
||||
application.register("event-form", EventFormController);
|
||||
|
||||
import TicketTypeFormController from "./ticket_type_form_controller";
|
||||
application.register("ticket-type-form", TicketTypeFormController);
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import React from "react"
|
||||
import { createRoot } from "react-dom/client"
|
||||
import { Button } from "@/components/button"
|
||||
|
||||
// Controller for testing shadcn/ui React components within a Stimulus context
|
||||
// Renders a React button component to verify the PostCSS and component setup
|
||||
export default class extends Controller {
|
||||
// Define targets for the controller
|
||||
static targets = ["container"]
|
||||
|
||||
// Initialize and render the React component when the controller connects
|
||||
connect() {
|
||||
console.log("Shadcn Button Test Controller connected")
|
||||
this.renderButton()
|
||||
}
|
||||
|
||||
// Render the React button component inside the target container
|
||||
renderButton() {
|
||||
const container = this.containerTarget
|
||||
const root = createRoot(container)
|
||||
|
||||
root.render(
|
||||
<div className="flex flex-col items-center gap-4 p-6">
|
||||
<h3 className="text-white text-lg font-semibold">Test Button Shadcn</h3>
|
||||
<Button
|
||||
variant="default"
|
||||
size="lg"
|
||||
className="bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700"
|
||||
onClick={this.handleClick}
|
||||
>
|
||||
Cliquez ici - PostCSS Test
|
||||
</Button>
|
||||
<p className="text-gray-300 text-sm">Ce bouton utilise shadcn/ui + Tailwind + PostCSS</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Handle button click events
|
||||
handleClick = () => {
|
||||
alert("✅ Le bouton shadcn fonctionne avec PostCSS !")
|
||||
console.log("Shadcn button clicked - PostCSS compilation successful")
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// Ticket Type Form Controller
|
||||
// Handles dynamic pricing calculations and form interactions
|
||||
export default class extends Controller {
|
||||
static targets = ["price", "quantity", "total"]
|
||||
|
||||
connect() {
|
||||
console.log("Ticket type form controller connected")
|
||||
this.updateTotal()
|
||||
}
|
||||
|
||||
// Update total revenue calculation when price or quantity changes
|
||||
updateTotal() {
|
||||
const price = parseFloat(this.priceTarget.value) || 0
|
||||
const quantity = parseInt(this.quantityTarget.value) || 0
|
||||
const total = price * quantity
|
||||
|
||||
// Format as currency
|
||||
const formatter = new Intl.NumberFormat('fr-FR', {
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
minimumFractionDigits: 2
|
||||
})
|
||||
|
||||
if (this.hasQuantityTarget && this.hasTotalTarget) {
|
||||
// For new ticket types, calculate potential revenue
|
||||
this.totalTarget.textContent = formatter.format(total)
|
||||
} else if (this.hasTotalTarget) {
|
||||
// For edit forms, calculate remaining potential revenue
|
||||
const soldTickets = parseInt(this.element.dataset.soldTickets) || 0
|
||||
const remainingQuantity = Math.max(0, quantity - soldTickets)
|
||||
const remainingRevenue = price * remainingQuantity
|
||||
this.totalTarget.textContent = formatter.format(remainingRevenue)
|
||||
}
|
||||
}
|
||||
|
||||
// Validate minimum quantity (for edit forms with sold tickets)
|
||||
validateQuantity() {
|
||||
const soldTickets = parseInt(this.element.dataset.soldTickets) || 0
|
||||
const quantity = parseInt(this.quantityTarget.value) || 0
|
||||
|
||||
if (quantity < soldTickets) {
|
||||
this.quantityTarget.value = soldTickets
|
||||
this.quantityTarget.setCustomValidity(`La quantité ne peut pas être inférieure à ${soldTickets} (billets déjà vendus)`)
|
||||
} else {
|
||||
this.quantityTarget.setCustomValidity('')
|
||||
}
|
||||
|
||||
this.updateTotal()
|
||||
}
|
||||
|
||||
// Format price input to ensure proper decimal places
|
||||
formatPrice() {
|
||||
const price = parseFloat(this.priceTarget.value)
|
||||
if (!isNaN(price)) {
|
||||
this.priceTarget.value = price.toFixed(2)
|
||||
}
|
||||
this.updateTotal()
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { clsx } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
// Utility function for conditionally joining CSS classes
|
||||
// Combines clsx (for conditional classes) with twMerge (for Tailwind CSS conflicts)
|
||||
// Usage: cn("class1", "class2", conditionalClass && "class3")
|
||||
export function cn(...inputs) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
Reference in New Issue
Block a user