diff --git a/.env.example b/.env.example index 2ebb16a..4383235 100644 --- a/.env.example +++ b/.env.example @@ -29,6 +29,15 @@ SMTP_PORT=1025 SMTP_AUTHENTICATION=plain SMTP_ENABLE_STARTTLS=false +# Production SMTP Configuration (set these in .env.production) +# SMTP_ADDRESS=smtp.example.com +# SMTP_PORT=587 +# SMTP_USERNAME=your_smtp_username +# SMTP_PASSWORD=your_smtp_password +# SMTP_AUTHENTICATION=plain +# SMTP_DOMAIN=example.com +# SMTP_STARTTLS=true + # Application variables STRIPE_API_KEY=1337 diff --git a/Procfile.dev b/Procfile.dev index c1cb248..96ee687 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,3 +1,3 @@ -web: env RUBY_DEBUG_OPEN=true bin/rails server -js: yarn build --watch +web: env RUBY_DEBUG_OPEN=true bin/rails server +js: yarn build:dev --watch css: yarn build:css --watch diff --git a/app/assets/stylesheets/application.postcss.css b/app/assets/stylesheets/application.postcss.css index cc9f6b6..39944f4 100644 --- a/app/assets/stylesheets/application.postcss.css +++ b/app/assets/stylesheets/application.postcss.css @@ -3,6 +3,9 @@ /* Import Tailwind using PostCSS */ @import "tailwindcss"; +/* Import flash message styles */ +@import "components/flash"; + /** Default text color */ body { color: #555555; diff --git a/app/assets/stylesheets/components/flash.css b/app/assets/stylesheets/components/flash.css new file mode 100644 index 0000000..d985310 --- /dev/null +++ b/app/assets/stylesheets/components/flash.css @@ -0,0 +1,39 @@ +/* Flash Messages - Theme Integration */ +.flash-message { + @apply max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mb-4; +} + +/* Base styles for all flash messages */ +.flash-message .flex { + @apply rounded-md p-4 border shadow-md; +} + +/* Success message styles */ +.flash-message-success { + @apply bg-green-50 border-green-100 text-green-800; +} + +/* Error message styles */ +.flash-message-error { + @apply bg-red-50 border-red-100 text-red-800; +} + +/* Warning message styles */ +.flash-message-warning { + @apply bg-yellow-50 border-yellow-100 text-yellow-800; +} + +/* Info message styles */ +.flash-message-info { + @apply bg-blue-50 border-blue-100 text-blue-800; +} + +/* Notice message styles */ +.flash-message-notice { + @apply bg-purple-50 border-purple-100 text-purple-800; +} + +/* Alert message styles */ +.flash-message-alert { + @apply bg-red-50 border-red-100 text-red-800; +} diff --git a/app/controllers/authentications/passwords_controller.rb b/app/controllers/authentications/passwords_controller.rb index edce788..f9f2cf3 100644 --- a/app/controllers/authentications/passwords_controller.rb +++ b/app/controllers/authentications/passwords_controller.rb @@ -23,9 +23,11 @@ class Authentications::PasswordsController < Devise::PasswordsController # protected - # def after_resetting_password_path_for(resource) - # super(resource) - # end + # Override to set a flash message on successful password reset + def after_resetting_password_path_for(resource) + flash[:notice] = "Votre mot de passe a été changé avec succès. Vous êtes maintenant connecté." + super(resource) + end # The path used after sending reset password instructions # def after_sending_reset_password_instructions_path_for(resource_name) diff --git a/app/controllers/authentications/sessions_controller.rb b/app/controllers/authentications/sessions_controller.rb index 6fdf49b..37e6a5f 100644 --- a/app/controllers/authentications/sessions_controller.rb +++ b/app/controllers/authentications/sessions_controller.rb @@ -9,9 +9,10 @@ class Authentications::SessionsController < Devise::SessionsController # end # POST /resource/sign_in - # def create - # super - # end + def create + super + flash[:notice] = "Connexion réussie !" if resource.persisted? + end # DELETE /resource/sign_out # def destroy diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 7dce8ce..4a4948c 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -3,17 +3,26 @@ class PagesController < ApplicationController # Skip authentication for public pages # skip_before_action :authenticate_user!, only: [ :home ] + before_action :authenticate_user!, only: [ :dashboard ] # Homepage showing featured parties def home # @parties = Party.published.featured.limit(3) @parties = Party.where(state: :published).order(created_at: :desc) - puts @parties + + if user_signed_in? + return redirect_to(dashboard_path) + end end # User dashboard showing personalized content # Accessible only to authenticated users def dashboard + @available_parties = Party.published.count + @events_this_week = Party.published.where("start_time BETWEEN ? AND ?", Date.current.beginning_of_week, Date.current.end_of_week).count + @today_parties = Party.published.where("DATE(start_time) = ?", Date.current).order(start_time: :asc) + @tomorrow_parties = Party.published.where("DATE(start_time) = ?", Date.current + 1).order(start_time: :asc) + @other_parties = Party.published.upcoming.where.not("DATE(start_time) IN (?)", [Date.current, Date.current + 1]).order(start_time: :asc).page(params[:page]) end # Events page showing all published parties with pagination diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d551c20..debee41 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,9 @@ module ApplicationHelper + # Convert prince from cents to float def format_price(cents) (cents.to_f / 100).round(2) end + + # Include flash message helpers + include FlashMessagesHelper end diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb new file mode 100644 index 0000000..4d86a1a --- /dev/null +++ b/app/helpers/flash_messages_helper.rb @@ -0,0 +1,34 @@ +module FlashMessagesHelper + def flash_class(type) + case type.to_s + when 'notice' then 'flash-message-success' + when 'success' then 'flash-message-success' + when 'error' then 'flash-message-error' + when 'alert' then 'flash-message-error' + when 'warning' then 'flash-message-warning' + when 'info' then 'flash-message-info' + else "flash-message-#{type}" + end + end + + def flash_icon(type) + case type.to_s + when 'notice', 'success' + content_tag :svg, class: "h-5 w-5 text-green-400", fill: "currentColor", viewBox: "0 0 20 20" do + content_tag :path, "", "fill-rule": "evenodd", "d": "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z", "clip-rule": "evenodd" + end + when 'error', 'alert' + content_tag :svg, class: "h-5 w-5 text-red-400", fill: "currentColor", viewBox: "0 0 20 20" do + content_tag :path, "", "fill-rule": "evenodd", "d": "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z", "clip-rule": "evenodd" + end + when 'warning' + content_tag :svg, class: "h-5 w-5 text-yellow-400", fill: "currentColor", viewBox: "0 0 20 20" do + content_tag :path, "", "fill-rule": "evenodd", "d": "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z", "clip-rule": "evenodd" + end + else + content_tag :svg, class: "h-5 w-5 text-blue-400", fill: "currentColor", viewBox: "0 0 20 20" do + content_tag :path, "", "fill-rule": "evenodd", "d": "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", "clip-rule": "evenodd" + end + end + end +end diff --git a/app/javascript/controllers/flash_message_controller.js b/app/javascript/controllers/flash_message_controller.js new file mode 100644 index 0000000..89e0b2d --- /dev/null +++ b/app/javascript/controllers/flash_message_controller.js @@ -0,0 +1,27 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + static targets = ["message"] + + connect() { + console.log("FlashMessageController mounted", this.element); + + // Auto-dismiss after 5 seconds + this.timeout = setTimeout(() => { + this.close() + }, 5000) + } + + disconnect() { + if (this.timeout) { + clearTimeout(this.timeout) + } + } + + close() { + this.element.classList.add('opacity-0', 'transition-opacity', 'duration-300') + setTimeout(() => { + this.element.remove() + }, 300) + } +} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index 2dd37f0..8847531 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -5,9 +5,12 @@ import { application } from "./application" import LogoutController from "./logout_controller" -import ShadcnTestController from "./shadcn_test_controller" +import FlashMessage from "./flash_message_controller" import CounterController from "./counter_controller" +import ShadcnTestController from "./shadcn_test_controller" -application.register("logout", LogoutController) -application.register("shadcn-test", ShadcnTestController) -application.register("counter", CounterController) +application.register("logout", LogoutController) // Allow logout using js +application.register("flash-message", FlashMessage) // Dismiss notification after 5 secondes +application.register("counter", CounterController) // Simple counter for homepage + +application.register("shadcn-test", ShadcnTestController) // Test controller for Shadcn diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb index b12dd0c..962cb5c 100644 --- a/app/views/devise/confirmations/new.html.erb +++ b/app/views/devise/confirmations/new.html.erb @@ -1,7 +1,6 @@