diff --git a/src/admin/pages/ProjectDetail.tsx b/src/admin/pages/ProjectDetail.tsx index cb06c9f..b2f6b71 100644 --- a/src/admin/pages/ProjectDetail.tsx +++ b/src/admin/pages/ProjectDetail.tsx @@ -81,10 +81,18 @@ export default function ProjectDetail() { const notes: ProjectNote[] = project?.project_notes || []; const { data: usersData } = useQuery(userListOptions("projects.view")); - const users: User[] = (usersData ?? []).map((u: ApiUser) => ({ - id: u.id, - name: `${u.first_name || ""} ${u.last_name || ""}`.trim() || u.username, - })); + // Only active users with projects.view — but keep the project's CURRENT + // assignee in the list even if they're now inactive, so the select still + // reflects the saved value (marked "(neaktivní)" so it's clear). + const assignedUserId = project?.responsible_user_id || ""; + const users: User[] = (usersData ?? []) + .filter((u: ApiUser) => u.is_active || String(u.id) === assignedUserId) + .map((u: ApiUser) => ({ + id: u.id, + name: + (`${u.first_name || ""} ${u.last_name || ""}`.trim() || u.username) + + (u.is_active ? "" : " (neaktivní)"), + })); // Reset form sync when navigating to a different project const formInitialized = useRef(false);