diff --git a/frontend/src/app/users/[id]/page.tsx b/frontend/src/app/users/[id]/page.tsx index 07240609..d5bf49fe 100644 --- a/frontend/src/app/users/[id]/page.tsx +++ b/frontend/src/app/users/[id]/page.tsx @@ -75,15 +75,25 @@ export default function UserDetailPage() { return `${person.last_name || ""} ${person.first_name || ""} ${person.patronymic || ""}`.trim() || "Пользователь"; }, [person]); - // Последний статус сотрудника + // Последний статус сотрудника (только события которые уже наступили) const latestAction = useMemo(() => { if (!person?.actions || person.actions.length === 0) return null; - return person.actions.reduce((latest, action) => + + const now = new Date(); + // Фильтруем только события которые уже наступили + const pastActions = person.actions.filter(action => + new Date(action.date) <= now + ); + + if (pastActions.length === 0) return null; + + // Из них берём последнее + return pastActions.reduce((latest, action) => new Date(action.date) > new Date(latest.date) ? action : latest ); }, [person?.actions]); - // Отсортированная история событий (от новых к старым) + // Отсортированная история событий (от новых к старым, показываем все включая будущие) const sortedActions = useMemo(() => { if (!person?.actions || person.actions.length === 0) return []; return [...person.actions].sort((a, b) => @@ -681,77 +691,82 @@ export default function UserDetailPage() {
- {sortedActions.map((action, index) => ( -
-
-
-
-
- - {action.action_display || action.action} - - {index === 0 && ( - текущий + {sortedActions.map((action, index) => { + // Проверяем является ли это событие текущим (последнее из наступивших) + const isCurrent = latestAction?.id === action.id; + + return ( +
+
+
+
+
+ + {action.action_display || action.action} + + {isCurrent && ( + текущий + )} +
+ {action.comment && ( +

{action.comment}

+ )} +
+
+ + {canManageActions && ( +
+ + +
)}
- {action.comment && ( -

{action.comment}

- )} -
-
- - {canManageActions && ( -
- - -
- )}
-
- ))} + ); + })}
)}