Add feedback functionality to EventsPageSection: Integrate FeedbackModal for event feedback submission, allowing users to provide feedback on selected events. Update event handling to manage feedback state and improve user interaction.
This commit is contained in:
@@ -4,6 +4,7 @@ import { useState, useEffect, useMemo, useRef } from "react";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { calculateEventStatus } from "@/lib/eventStatus";
|
||||
import FeedbackModal from "@/components/FeedbackModal";
|
||||
|
||||
interface Event {
|
||||
id: string;
|
||||
@@ -88,6 +89,7 @@ export default function EventsPageSection({
|
||||
const [error, setError] = useState<string>("");
|
||||
const [currentMonth, setCurrentMonth] = useState(new Date());
|
||||
const [selectedEvent, setSelectedEvent] = useState<Event | null>(null);
|
||||
const [feedbackEventId, setFeedbackEventId] = useState<string | null>(null);
|
||||
|
||||
// Helper function pour obtenir le statut d'un événement
|
||||
const getEventStatus = (event: Event) => calculateEventStatus(event.date);
|
||||
@@ -500,7 +502,7 @@ export default function EventsPageSection({
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
router.push(`/feedback/${event.id}`);
|
||||
setFeedbackEventId(event.id);
|
||||
}}
|
||||
className="w-full px-4 py-2 border border-pixel-gold/50 bg-black/40 text-white uppercase text-xs tracking-widest rounded hover:bg-pixel-gold/10 hover:border-pixel-gold transition"
|
||||
>
|
||||
@@ -817,8 +819,15 @@ export default function EventsPageSection({
|
||||
)}
|
||||
{selectedEvent && getEventStatus(selectedEvent) === "PAST" && (
|
||||
<div className="pt-4 border-t border-pixel-gold/20">
|
||||
<button className="w-full px-4 py-3 border border-gray-600/50 bg-gray-900/20 text-gray-500 uppercase text-sm tracking-widest rounded cursor-not-allowed">
|
||||
Événement terminé
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setFeedbackEventId(selectedEvent.id);
|
||||
setSelectedEvent(null);
|
||||
}}
|
||||
className="w-full px-4 py-3 border border-pixel-gold/50 bg-black/40 text-white uppercase text-sm tracking-widest rounded hover:bg-pixel-gold/10 hover:border-pixel-gold transition"
|
||||
>
|
||||
Donner un feedback
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
@@ -826,6 +835,12 @@ export default function EventsPageSection({
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Feedback Modal */}
|
||||
<FeedbackModal
|
||||
eventId={feedbackEventId}
|
||||
onClose={() => setFeedbackEventId(null)}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user