Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/talks/MyTalksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { Talk, Room } from '@/lib/types';
import { Talk } from '@/lib/types';
import { Pencil, Plus, Trash2, CalendarPlus } from 'lucide-react';
import { useSession } from 'next-auth/react';
import { useState, useMemo } from 'react';
Expand Down
3 changes: 1 addition & 2 deletions app/components/talks/PendingTalksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { levels } from '@/lib/mock-data';
import { Talk, TalkStatus } from '@/lib/types';
import { isOrganizer, isSpeaker } from '@/utils/auth.utils';
import { Pencil, Plus, Trash2 } from 'lucide-react';
Expand Down Expand Up @@ -126,7 +125,7 @@ export default function PendingTalksList({
<CardDescription className="text-muted-foreground flex space-x-2 text-sm">
<span>{talk.subjects?.name}</span>
<span>•</span>
<span>{levels.find((l) => l.value === talk.level)?.label}</span>
<span>{talk.level}</span>
<span>•</span>
<span>{talk.duration} min</span>
</CardDescription>
Expand Down
46 changes: 0 additions & 46 deletions app/components/talks/ScheduledTalksList.tsx

This file was deleted.

75 changes: 52 additions & 23 deletions app/components/talks/TalkDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,23 @@ import {
SelectValue,
} from '@/components/ui/select';
import { Textarea } from '@/components/ui/textarea';
import { durations, emptyTalk, levels } from '@/lib/mock-data';
import { Talk, TalkLevel } from '@/lib/types';
import { useSession } from 'next-auth/react';
import { FormEvent, useEffect, useState } from 'react';

// form subjects (must match your DB subjects.name)
export const subjects = [
'JavaScript',
'TypeScript',
'React',
'Next.js',
'Node.js',
'Prisma',
'GraphQL',
'DevOps',
'Architecture',
'UX/UI',
'Mobile',
'Security',
'Testing',
'Performance',
'Accessibility',
const durations = [
{ value: 30, label: '30 minutes' },
{ value: 60, label: '1 heure' },
{ value: 120, label: '2 heures' },
{ value: 180, label: '3 heures' },
{ value: 240, label: '4 heures' },
{ value: 300, label: '5 heures' },
{ value: 360, label: '6 heures' },
{ value: 420, label: '7 heures' },
{ value: 480, label: '8 heures' },
{ value: 540, label: '9 heures' },
{ value: 600, label: '10 heures' },
{ value: 660, label: '11 heures' },
];

interface TalkDialogProps {
Expand All @@ -53,17 +48,51 @@ interface TalkDialogProps {

export default function TalkDialog({ isOpen, setIsOpen, talk, isNew, onSave }: TalkDialogProps) {
const { data: session } = useSession();
const [currentTalk, setCurrentTalk] = useState<Omit<Talk, 'id'>>(emptyTalk);
const emptyTalk = {
id: 0,
title: '',
description: '',
topic: '',
duration: 30,
level: 'beginner',
speakerId: 0,
};
const [currentTalk, setCurrentTalk] = useState(emptyTalk);
const [subjects, setSubjects] = useState<string[]>([]);
const [levels, setLevels] = useState<{ value: TalkLevel; label: string }[]>([]);

useEffect(() => {
if (!isOpen) return;
if (!session?.user?.id) throw new Error('User ID is required');
setCurrentTalk(
isNew ? { ...emptyTalk, speakerId: Number(session.user.id) } : { ...(talk as Talk) },
);
if (isNew) {
setCurrentTalk({ ...emptyTalk, speakerId: Number(session.user.id) });
} else if (talk) {
setCurrentTalk({
id: talk.id,
title: talk.title,
description: talk.description,
topic: talk.subjects?.name || '',
duration: talk.duration,
level: talk.level,
speakerId: talk.speakerId,
});
} else {
setCurrentTalk(emptyTalk);
}

// Fetch subjects
fetch('/api/references/subjects')
.then((res) => res.json())
.then((data) => setSubjects(Array.isArray(data) ? data : []))
.catch(() => setSubjects([]));
// Fetch levels
fetch('/api/references/talkLevels')
.then((res) => res.json())
.then((data) => setLevels(Array.isArray(data) ? data : []))
.catch(() => setLevels([]));
}, [isOpen, isNew, talk, session]);

const handleInputChange = (field: keyof Omit<Talk, 'id'>, value: string | number | TalkLevel) => {
const handleInputChange = (field: string, value: string | number | TalkLevel) => {
setCurrentTalk({ ...currentTalk, [field]: value });
};

Expand Down
2 changes: 1 addition & 1 deletion app/components/talks/TalksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { Talk, Room } from '@/lib/types';
import { Talk } from '@/lib/types';
import { Pencil, Plus, Trash2, CalendarPlus } from 'lucide-react';
import { useSession } from 'next-auth/react';
import { useState, useMemo } from 'react';
Expand Down
21 changes: 5 additions & 16 deletions app/components/talks/TalksSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface Slot {

interface TalksScheduleProps {
talks: Talk[];
onScheduleTalk: (talkId: string, slotId: string) => void;
onScheduleTalk: (talkId: string) => void;
}

export default function TalksSchedule({ talks, onScheduleTalk }: TalksScheduleProps) {
Expand All @@ -65,17 +65,6 @@ export default function TalksSchedule({ talks, onScheduleTalk }: TalksSchedulePr
const [slots, setSlots] = useState<Slot[]>([]);
const [availableSlots, setAvailableSlots] = useState<Slot[]>([]);

useEffect(() => {
const [dateParam] = selectedDate.toISOString().split('T');
Promise.all([
fetch(`/api/rooms/availability?date=${dateParam}`).then((r) => r.json()),
fetch(`/api/schedules?date=${dateParam}`).then((r) => r.json()),
]).catch((err) => {
console.error(err);
alert('Erreur de chargement');
});
}, [selectedDate]);

// 1️⃣ Fetch rooms+slots once on mount
useEffect(() => {
const [dateParam] = selectedDate.toISOString().split('T'); // "2025-05-16"
Expand Down Expand Up @@ -103,7 +92,7 @@ export default function TalksSchedule({ talks, onScheduleTalk }: TalksSchedulePr
console.error(err);
alert(err.message);
});
}, [selectedDate]);
}, [selectedDate, selectedTalk]);

// 2️⃣ Compute availableSlots whenever date/room/slots change
useEffect(() => {
Expand Down Expand Up @@ -145,7 +134,7 @@ export default function TalksSchedule({ talks, onScheduleTalk }: TalksSchedulePr
throw new Error(data.error || 'Échec de la planification');
}

onScheduleTalk(selectedTalk, selectedSlot);
onScheduleTalk(selectedTalk);

const talk = talks.find((t) => t.id.toString() === selectedTalk)!;
const room = rooms.find((r) => r.roomId === data.slot.roomId)!;
Expand All @@ -162,8 +151,8 @@ export default function TalksSchedule({ talks, onScheduleTalk }: TalksSchedulePr

setSelectedTalk('');
setSelectedSlot('');
} catch (err: any) {
alert(err.message);
} catch (err) {
alert(err);
} finally {
setIsScheduling(false);
}
Expand Down
154 changes: 0 additions & 154 deletions app/lib/mock-data.ts

This file was deleted.

Loading
Loading