Skip to content

Commit

Permalink
fix: show button based on user_id not on email
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinx0 committed Nov 7, 2024
1 parent cc000ea commit 17f7c05
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/AsignarSolicitudButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type AsignarSolicitudButtonProps = {
export default function AsignarSolicitudButton({ helpRequest }: AsignarSolicitudButtonProps) {
const { toggleModal } = useModal();
const session = useSession();

const userId = session.user?.id;
const MODAL_NAME = `Solicitud-${helpRequest.id}`;

const {
Expand All @@ -43,6 +43,7 @@ export default function AsignarSolicitudButton({ helpRequest }: AsignarSolicitud
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['help_request_assignments'] });
queryClient.invalidateQueries({ queryKey: ['help_requests', { user_id: userId, type: 'necesita' }] });
},
onError: (e) => {
console.error('Error al asignarte a la petición de ayuda', e);
Expand All @@ -58,6 +59,7 @@ export default function AsignarSolicitudButton({ helpRequest }: AsignarSolicitud
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['help_request_assignments'] });
queryClient.invalidateQueries({ queryKey: ['help_requests', { user_id: userId, type: 'necesita' }] });
},
onError: (e) => {
console.error('Error al asignarte a la petición de ayuda', e);
Expand Down Expand Up @@ -96,7 +98,7 @@ export default function AsignarSolicitudButton({ helpRequest }: AsignarSolicitud
);

// Verifica el email dentro de additional_info utilizando un casting y encadenamiento opcional
if ((helpRequest.additional_info as HelpRequestAdditionalInfo)?.email === session.user.email) return null;
if (helpRequest.user_id === session.user.id) return null;

return (
<>
Expand Down

0 comments on commit 17f7c05

Please sign in to comment.