feat: Implement event image upload system for promoters
- Add Active Storage migrations for file attachments - Update Event model to handle image uploads with validation - Replace image URL fields with file upload in forms - Add client-side image preview with validation - Update all views to display uploaded images properly - Fix JSON serialization to prevent stack overflow in API - Add custom image validation methods for format and size - Include image processing variants for different display sizes - Fix promotion code test infrastructure and Stripe configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -664,4 +664,37 @@ export default class extends Controller {
|
||||
this.hideMessage("geocoding-success")
|
||||
this.hideMessage("geocoding-progress")
|
||||
}
|
||||
|
||||
// Preview selected image
|
||||
previewImage(event) {
|
||||
const file = event.target.files[0]
|
||||
if (!file) return
|
||||
|
||||
// Validate file type
|
||||
if (!file.type.startsWith('image/')) {
|
||||
alert('Veuillez sélectionner une image valide.')
|
||||
event.target.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
// Validate file size (5MB)
|
||||
if (file.size > 5 * 1024 * 1024) {
|
||||
alert('L\'image ne doit pas dépasser 5MB.')
|
||||
event.target.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
// Show preview
|
||||
const reader = new FileReader()
|
||||
reader.onload = (e) => {
|
||||
const previewContainer = document.getElementById('image-preview')
|
||||
const previewImg = document.getElementById('preview-img')
|
||||
|
||||
if (previewContainer && previewImg) {
|
||||
previewImg.src = e.target.result
|
||||
previewContainer.classList.remove('hidden')
|
||||
}
|
||||
}
|
||||
reader.readAsDataURL(file)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user