From 7ff180bea4c6c867b3ad17ba2facf8be847455a9 Mon Sep 17 00:00:00 2001 From: ghotso <168240713+ghotso@users.noreply.github.com> Date: Mon, 18 Aug 2025 23:03:37 +0200 Subject: [PATCH] fix(incidents): fetch and display assignee in detail dialog via assigned_users with fallback --- .../incident/detail-dialog/IncidentDetailContent.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/application/src/components/schedule-incident/incident/detail-dialog/IncidentDetailContent.tsx b/application/src/components/schedule-incident/incident/detail-dialog/IncidentDetailContent.tsx index 7fe8737..3424dee 100644 --- a/application/src/components/schedule-incident/incident/detail-dialog/IncidentDetailContent.tsx +++ b/application/src/components/schedule-incident/incident/detail-dialog/IncidentDetailContent.tsx @@ -25,19 +25,20 @@ export const IncidentDetailContent = ({ onClose, assignedUser }: IncidentDetailContentProps) => { - // Fetch assigned user details if one wasn't provided and there's an assigned_to field + // Fetch assigned user details if none was provided; prefer server field + const assigneeId = incident?.assigned_users || incident?.assigned_to; const { data: fetchedUser } = useQuery({ - queryKey: ['user', incident?.assigned_to], + queryKey: ['user', assigneeId], queryFn: async () => { - if (!incident?.assigned_to) return null; + if (!assigneeId) return null; try { - return await userService.getUser(incident.assigned_to); + return await userService.getUser(assigneeId); } catch (error) { console.error("Failed to fetch assigned user:", error); return null; } }, - enabled: !!incident?.assigned_to && !assignedUser, + enabled: !!assigneeId && !assignedUser, staleTime: 300000 // Cache for 5 minutes });