duties widget correction 3

This commit is contained in:
Alma 2025-04-13 18:53:55 +02:00
parent b7eb4d90c0
commit 1e01d2e356
3 changed files with 48 additions and 55 deletions

View File

@ -152,15 +152,9 @@ export async function GET(request: NextRequest) {
const tasks = data.result const tasks = data.result
.filter((task: any) => { .filter((task: any) => {
// Convert status to number to ensure consistent comparison // Skip all completed tasks (status 5), whether they are main tasks or subtasks
const taskStatus = Number(task.status); if (task.status === 5) {
console.log(`Filtering out completed task ${task.id} (type: ${task.type || 'main'})`);
// Log the raw status value for debugging
console.log(`Raw task ${task.id} status: ${task.status}, converted: ${taskStatus}`);
// Skip tasks that are done (status 3 or 5)
if (taskStatus === 3 || taskStatus === 5) {
console.log(`Filtering out completed task ${task.id} (type: ${task.type || 'main'}, status: ${taskStatus})`);
return false; return false;
} }
@ -170,7 +164,7 @@ export async function GET(request: NextRequest) {
// Only show tasks where the user is the editor // Only show tasks where the user is the editor
const isUserEditor = taskEditorId === currentUserId; const isUserEditor = taskEditorId === currentUserId;
console.log(`Task ${task.id}: status=${taskStatus}, type=${task.type || 'main'}, isUserEditor=${isUserEditor}`); console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, isUserEditor=${isUserEditor}`);
return isUserEditor; return isUserEditor;
}) })
.map((task: any) => ({ .map((task: any) => ({
@ -178,7 +172,7 @@ export async function GET(request: NextRequest) {
headline: task.headline, headline: task.headline,
projectName: task.projectName, projectName: task.projectName,
projectId: task.projectId, projectId: task.projectId,
status: Number(task.status), // Ensure status is a number status: task.status,
dateToFinish: task.dateToFinish || null, dateToFinish: task.dateToFinish || null,
milestone: task.type || null, milestone: task.type || null,
details: task.description || null, details: task.description || null,
@ -187,7 +181,7 @@ export async function GET(request: NextRequest) {
editorId: task.editorId, editorId: task.editorId,
editorFirstname: task.editorFirstname, editorFirstname: task.editorFirstname,
editorLastname: task.editorLastname, editorLastname: task.editorLastname,
type: task.type || null type: task.type || null // Added type field to identify subtasks
})); }));
console.log(`Found ${tasks.length} tasks assigned to user ${userId}`); console.log(`Found ${tasks.length} tasks assigned to user ${userId}`);

View File

@ -929,9 +929,9 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
<Plus className="mr-2 h-4 w-4" /> <Plus className="mr-2 h-4 w-4" />
<span className="font-medium">Nouveau calendrier</span> <span className="font-medium">Nouveau calendrier</span>
</Button> </Button>
<Button <Button
onClick={() => { onClick={() => {
setSelectedEvent(null); setSelectedEvent(null);
setEventForm({ setEventForm({
title: "", title: "",
description: null, description: null,
@ -947,30 +947,30 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
> >
<Plus className="mr-2 h-4 w-4" /> <Plus className="mr-2 h-4 w-4" />
<span className="font-medium">Nouvel événement</span> <span className="font-medium">Nouvel événement</span>
</Button> </Button>
</div> </div>
<Tabs value={view} className="w-auto"> <Tabs value={view} className="w-auto">
<TabsList> <TabsList>
<TabsTrigger <TabsTrigger
value="dayGridMonth" value="dayGridMonth"
onClick={() => handleViewChange("dayGridMonth")} onClick={() => handleViewChange("dayGridMonth")}
> >
Mois Mois
</TabsTrigger> </TabsTrigger>
<TabsTrigger <TabsTrigger
value="timeGridWeek" value="timeGridWeek"
onClick={() => handleViewChange("timeGridWeek")} onClick={() => handleViewChange("timeGridWeek")}
> >
Semaine Semaine
</TabsTrigger> </TabsTrigger>
<TabsTrigger <TabsTrigger
value="timeGridDay" value="timeGridDay"
onClick={() => handleViewChange("timeGridDay")} onClick={() => handleViewChange("timeGridDay")}
> >
Jour Jour
</TabsTrigger> </TabsTrigger>
</TabsList> </TabsList>
</Tabs> </Tabs>
</div> </div>
@ -1021,26 +1021,26 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
<div className="h-96 flex items-center justify-center"> <div className="h-96 flex items-center justify-center">
<Loader2 className="h-8 w-8 animate-spin text-primary" /> <Loader2 className="h-8 w-8 animate-spin text-primary" />
<span className="ml-2">Chargement des événements...</span> <span className="ml-2">Chargement des événements...</span>
</div> </div>
) : ( ) : (
<FullCalendar <FullCalendar
ref={calendarRef} ref={calendarRef}
plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]} plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
initialView={view} initialView={view}
headerToolbar={{ headerToolbar={{
left: "prev,next today", left: "prev,next today",
center: "title", center: "title",
right: "", right: "",
}} }}
events={calendars events={calendars
.filter(cal => visibleCalendarIds.includes(cal.id)) .filter(cal => visibleCalendarIds.includes(cal.id))
.flatMap(cal => .flatMap(cal =>
(cal.events || []).map(event => ({ (cal.events || []).map(event => ({
id: event.id, id: event.id,
title: event.title, title: event.title,
start: new Date(event.start), start: new Date(event.start),
end: new Date(event.end), end: new Date(event.end),
allDay: event.isAllDay, allDay: event.isAllDay,
description: event.description, description: event.description,
location: event.location, location: event.location,
calendarId: event.calendarId, calendarId: event.calendarId,
@ -1119,12 +1119,12 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
minute: '2-digit', minute: '2-digit',
hour12: false hour12: false
}} }}
/> />
)} )}
</Card> </Card>
{/* Calendar dialog */} {/* Calendar dialog */}
<CalendarDialog <CalendarDialog
open={isCalendarModalOpen} open={isCalendarModalOpen}
onClose={() => setIsCalendarModalOpen(false)} onClose={() => setIsCalendarModalOpen(false)}
onSave={handleCalendarSave} onSave={handleCalendarSave}

View File

@ -105,13 +105,12 @@ export function Duties() {
return; return;
} }
// Filter out all tasks with done status (3 or 5) and sort by dateToFinish // Filter out all tasks and subtasks with status 5 (Done) and sort by dateToFinish
const sortedTasks = data const sortedTasks = data
.filter((task: Task) => { .filter((task: Task) => {
const status = Number(task.status); const isNotDone = task.status !== 5;
const isNotDone = status !== 3 && status !== 5;
// Log task details for debugging // Log task details for debugging
console.log(`Task ${task.id}: status=${status}, type=${task.type || 'main'}, dateToFinish=${task.dateToFinish}, isNotDone=${isNotDone}`); console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, dateToFinish=${task.dateToFinish}, isNotDone=${isNotDone}`);
return isNotDone; return isNotDone;
}) })
.sort((a: Task, b: Task) => { .sort((a: Task, b: Task) => {