From 45a634de927b33a371b66d1fe55dc3f9a1e37c27 Mon Sep 17 00:00:00 2001 From: lizerk Date: Wed, 18 Mar 2026 11:37:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/app/users/[id]/page.tsx | 153 +++++++++++++++------------ 1 file changed, 84 insertions(+), 69 deletions(-) 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 && ( -
- - -
- )}
-
- ))} + ); + })}
)}