diff --git a/src/components/PhoneInfo.js b/src/components/PhoneInfo.js new file mode 100644 index 00000000..e1ff465b --- /dev/null +++ b/src/components/PhoneInfo.js @@ -0,0 +1,27 @@ +import { useQuery } from '@tanstack/react-query'; +import { helpRequestService } from '@/lib/service'; +import { useSession } from '@/context/SessionProvider'; + +export default function PhoneInfo({ caseInfo }) { + const session = useSession(); + + const { + data: assignments, + isLoading, + error, + } = useQuery({ + queryKey: ['help_request_assignments', { id: caseInfo.id }], + queryFn: () => helpRequestService.getAssignments(caseInfo.id), + }); + + if (error || isLoading) return <>>; + + const userAssignment = assignments?.find((x) => x.user_id === session.user?.id); + + return ( + + Contacto:{' '} + {!!userAssignment ? caseInfo.contact_info : 'Ayuda a esta persona para ver sus datos de contacto'} + + ); +} diff --git a/src/components/SolicitudCard.tsx b/src/components/SolicitudCard.tsx index 12a8bc17..bc9dad49 100644 --- a/src/components/SolicitudCard.tsx +++ b/src/components/SolicitudCard.tsx @@ -2,10 +2,11 @@ import { AlertTriangle, Calendar, MapPin, MapPinned, Megaphone, Phone, Users } f import { tiposAyudaOptions } from '@/helpers/constants'; import Link from 'next/link'; import { useSession } from '@/context/SessionProvider'; -import { HelpRequestAdditionalInfo, HelpRequestData } from '@/types/Requests'; +import { HelpRequestAdditionalInfo, HelpRequestData, HelpRequestAssignmentData } from '@/types/Requests'; import { Town } from '@/types/Town'; import AsignarSolicitudButton from '@/components/AsignarSolicitudButton'; import SolicitudHelpCount from '@/components/SolicitudHelpCount'; +import PhoneInfo from '@/components/PhoneInfo.js'; type SolicitudCardProps = { caso: HelpRequestData; @@ -103,9 +104,7 @@ export default function SolicitudCard({ {caso.contact_info && (