Skip to content

Commit 47cefaa

Browse files
fixes
1 parent 6a77a1b commit 47cefaa

4 files changed

Lines changed: 27 additions & 73 deletions

File tree

MtdrSpring/backend/frontend-service/src/main/frontend/src/components/pages/home/AssignUserDialog.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ import { useUserResolver } from "../../hooks/useUserResolver"; // Agregar import
1818

1919
// Definir las interfaces basadas en los datos reales del API
2020
interface UserType {
21-
readonly id?: string;
22-
readonly userId?: string;
23-
readonly name?: string;
24-
readonly email?: string;
25-
readonly avatar?: string;
26-
readonly role?: string | null;
21+
id: string;
22+
name: string;
23+
email: string;
24+
avatar: string | null;
25+
role?: string | null;
2726
}
2827

2928
interface AssignUserDialogProps {
@@ -86,8 +85,12 @@ export function AssignUserDialog({
8685

8786
const data = await response.json();
8887

89-
// Extraer los IDs de usuario únicos
90-
const userIds = [...new Set(data.map((user: any) => user.userId).filter(Boolean))];
88+
// Extraer los IDs de usuario únicos - CORREGIR AQUÍ
89+
const userIds = [...new Set(
90+
data
91+
.filter((user: any) => user.userId && typeof user.userId === 'string')
92+
.map((user: any) => user.userId)
93+
)] as string[];
9194

9295
// Resolver nombres de usuario si hay IDs
9396
let userNames: Record<string, string> = {};
@@ -100,11 +103,11 @@ export function AssignUserDialog({
100103
const resolvedName = userNames[user.userId];
101104

102105
return {
103-
id: user.userId, // Usar userId como id
104-
name: resolvedName || user.name || `Usuario ${user.userId.slice(-8)}`, // Usar nombre resuelto, nombre original o fallback
105-
email: user.email || "",
106+
id: user.userId || '', // Asegurar que nunca sea undefined
107+
name: resolvedName || user.name || `Usuario ${user.userId?.slice(-8) || ''}`, // Usar nombre resuelto, nombre original o fallback
108+
email: user.email || '',
106109
avatar: user.avatar || null,
107-
role: user.role,
110+
role: user.role || null,
108111
};
109112
});
110113

MtdrSpring/backend/frontend-service/src/main/frontend/src/components/pages/home/Dashboard.tsx

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,13 @@ export default function Dashboard() {
242242
}, {});
243243
setMemberRoles(rolesMap);
244244

245-
// Extraer IDs de usuario únicos y resolver nombres
246-
const userIds = [...new Set(members.map((member: any) => member.userId).filter(Boolean))];
245+
// Extraer IDs de usuario únicos y resolver nombres - ALTERNATIVA SIMPLE
246+
const userIds: string[] = [...new Set(
247+
members
248+
.map((member: any) => member.userId)
249+
.filter(Boolean)
250+
)] as string[];
251+
247252
if (userIds.length > 0) {
248253
const resolvedNames = await resolveUserNames(userIds);
249254
setMemberNames(resolvedNames);
@@ -310,59 +315,6 @@ export default function Dashboard() {
310315
}, [availableTeams]);
311316

312317
// Memoizar datos de los charts para evitar recálculos innecesarios
313-
const chartData = useMemo(() => {
314-
// Mover toda la lógica de los charts aquí
315-
return {
316-
hoursBySprintAndDeveloper: sprints.reduce((acc: Record<string, Record<string, number>>, sprint) => {
317-
const currentSprintTasks = sprintTasks[sprint.sprintId] || [];
318-
319-
if (!acc[sprint.name]) {
320-
acc[sprint.name] = {};
321-
}
322-
323-
currentSprintTasks.forEach((task: Task) => {
324-
if (task.assignee && task.realHours) {
325-
const developerName = getUserDisplayName(task.assignee);
326-
if (!acc[sprint.name][developerName]) {
327-
acc[sprint.name][developerName] = 0;
328-
}
329-
acc[sprint.name][developerName] += task.realHours;
330-
}
331-
});
332-
333-
return acc;
334-
}, {}),
335-
336-
tasksBySprintAndDeveloper: sprints.reduce((acc: Record<string, Record<string, { total: number; completed: number }>>, sprint) => {
337-
const currentSprintTasks = sprintTasks[sprint.sprintId] || [];
338-
339-
if (!acc[sprint.name]) {
340-
acc[sprint.name] = {};
341-
}
342-
343-
currentSprintTasks.forEach((task: Task) => {
344-
if (task.assignee) {
345-
const developerName = getUserDisplayName(task.assignee);
346-
if (!acc[sprint.name][developerName]) {
347-
acc[sprint.name][developerName] = { total: 0, completed: 0 };
348-
}
349-
acc[sprint.name][developerName].total++;
350-
if (task.status === "COMPLETED") {
351-
acc[sprint.name][developerName].completed++;
352-
}
353-
}
354-
});
355-
356-
return acc;
357-
}, {}),
358-
359-
totalRealHoursBySprint: sprints.map(sprint => {
360-
const tasks = sprintTasks[sprint.sprintId] || [];
361-
return tasks.reduce((total, task) => total + (task.realHours || 0), 0);
362-
}),
363-
};
364-
}, [sprints, sprintTasks, getUserDisplayName]);
365-
366318
// Show a loading state while Clerk is initializing
367319
if (!isLoaded) {
368320
return (

MtdrSpring/backend/frontend-service/src/main/frontend/src/components/pages/home/Sprints.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ export default function Sprints() {
115115

116116
const data = await response.json();
117117

118-
// Obtener todos los IDs de usuarios únicos que tienen asignee
119-
const assigneeIds = [...new Set(data
118+
// Obtener todos los IDs de usuarios únicos que tienen asignee - VERSIÓN MEJORADA
119+
const assigneeIds = [...new Set(
120+
data
120121
.map((task: ServerTask) => task.assignee)
121-
.filter((assignee): assignee is string => Boolean(assignee))
122-
)];
123-
122+
.filter((assignee:any): assignee is string => Boolean(assignee) && typeof assignee === 'string')
123+
)] as string[];
124124
// Resolver nombres de usuario si hay assignees
125125
let userNames: Record<string, string> = {};
126126
if (assigneeIds.length > 0) {

MtdrSpring/backend/frontend-service/src/main/frontend/src/components/pages/home/TeamManagementModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { useState, useEffect } from "react";
3-
import React from "react";
43
import { useAuth } from "@clerk/clerk-react";
54
import { Users, Plus, X, UserPlus } from "lucide-react";
65

0 commit comments

Comments
 (0)