diff --git a/src/app/solicitudes/[id]/page.tsx b/src/app/solicitudes/[id]/page.tsx index 491bef0..2026773 100644 --- a/src/app/solicitudes/[id]/page.tsx +++ b/src/app/solicitudes/[id]/page.tsx @@ -56,7 +56,7 @@ export default function CasoDetalle() { - + ); } diff --git a/src/components/Comments/SolicitudComments.tsx b/src/components/Comments/SolicitudComments.tsx index cd7a5ee..3f6a47e 100644 --- a/src/components/Comments/SolicitudComments.tsx +++ b/src/components/Comments/SolicitudComments.tsx @@ -1,4 +1,4 @@ -import { HelpRequestAssignmentData, HelpRequestComment } from '@/types/Requests'; +import { HelpRequestAssignmentData, HelpRequestComment, HelpRequestData } from '@/types/Requests'; import { useQuery } from '@tanstack/react-query'; import { helpRequestService } from '@/lib/service'; import { useSession } from '@/context/SessionProvider'; @@ -7,17 +7,17 @@ import CommentForm from '@/components/Comments/CommentForm'; import { useRole } from '@/context/RoleProvider'; type SolicitudCommentsProps = { - request_id: number; + request: HelpRequestData; }; -export default function SolicitudComments({ request_id }: SolicitudCommentsProps) { +export default function SolicitudComments({ request }: SolicitudCommentsProps) { const { data: comments, isLoading, error, } = useQuery({ - queryKey: ['comments', { request_id: request_id }], - queryFn: () => helpRequestService.getComments(request_id), + queryKey: ['comments', { request_id: request.id }], + queryFn: () => helpRequestService.getComments(request.id), }); const { user } = useSession(); @@ -29,8 +29,8 @@ export default function SolicitudComments({ request_id }: SolicitudCommentsProps isLoading: isLoadingAssignments, error: errorAssignments, } = useQuery({ - queryKey: ['help_request_assignments', { id: request_id }], - queryFn: () => helpRequestService.getAssignments(request_id), + queryKey: ['help_request_assignments', { id: request.id }], + queryFn: () => helpRequestService.getAssignments(request.id), }); if (!user) return null; @@ -54,15 +54,16 @@ export default function SolicitudComments({ request_id }: SolicitudCommentsProps const userAssignment = assignments.find((x) => x.user_id === user?.id); const userIsAssigned = !!userAssignment; + const userIsOwner = user.id === request.user_id; - if (!userIsAssigned && !isAdmin) return null; + if (!userIsAssigned && !isAdmin && !userIsOwner) return null; return (
{comments.map((comment) => ( ))} - +
); }