fix(incidents): update detail dialog and PDF generation to prefer assigned_users over assigned_to for assignee
This commit is contained in:
+5
-5
@@ -23,19 +23,19 @@ export {
|
||||
|
||||
// Legacy component - keeping this for backward compatibility with other imports
|
||||
export const IncidentDetailSections = ({ incident }: { incident: IncidentItem | null }) => {
|
||||
// Fetch assigned user details if there's an assigned_to field
|
||||
// Fetch assigned user details if there's an assigned field (prefer assigned_users, fallback to assigned_to)
|
||||
const { data: assignedUser } = useQuery({
|
||||
queryKey: ['user', incident?.assigned_to],
|
||||
queryKey: ['user', incident?.assigned_users || incident?.assigned_to],
|
||||
queryFn: async () => {
|
||||
if (!incident?.assigned_to) return null;
|
||||
if (!(incident?.assigned_users || incident?.assigned_to)) return null;
|
||||
try {
|
||||
return await userService.getUser(incident.assigned_to);
|
||||
return await userService.getUser(incident?.assigned_users || incident?.assigned_to);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch assigned user:", error);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
enabled: !!incident?.assigned_to,
|
||||
enabled: !!(incident?.assigned_users || incident?.assigned_to),
|
||||
staleTime: 300000 // Cache for 5 minutes
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user