diff --git a/src/app/solicitud/page.js b/src/app/solicitud/page.js deleted file mode 100644 index 861953ab..00000000 --- a/src/app/solicitud/page.js +++ /dev/null @@ -1,21 +0,0 @@ -import { ArrowLeft } from 'lucide-react'; -import Link from 'next/link'; - -export default function Solicitud() { - return ( -
-
- - - Volver - -
-
-

No se encontrĂ³ la solicitud.

-
-
- ); -} diff --git a/src/app/solicitud/[id]/page.js b/src/app/solicitudes/[id]/page.tsx similarity index 70% rename from src/app/solicitud/[id]/page.js rename to src/app/solicitudes/[id]/page.tsx index 328b35f2..72bd429f 100644 --- a/src/app/solicitud/[id]/page.js +++ b/src/app/solicitudes/[id]/page.tsx @@ -1,37 +1,33 @@ 'use client'; -import { useEffect, useState } from 'react'; import { useParams } from 'next/navigation'; -import { supabase } from '@/lib/supabase/client'; import { ArrowLeft } from 'lucide-react'; import SolicitudCard from '@/components/SolicitudCard'; import { useTowns } from '@/context/TownProvider'; +import { useQuery } from '@tanstack/react-query'; +import { HelpRequestData } from '@/types/Requests'; +import { helpRequestService } from '@/lib/service'; export default function CasoDetalle() { const params = useParams(); const { id } = params; - const [caso, setCaso] = useState(null); const towns = useTowns(); - const [loading, setLoading] = useState(true); - useEffect(() => { - async function fetchCaso() { - const { data, error } = await supabase.from('help_requests').select('*').eq('id', id).single(); - if (error) { - console.error('Error fetching caso:', error); - } else { - setCaso(data); - } - setLoading(false); - } - fetchCaso(); - }, [id]); - if (loading) { + const { + data: request, + isLoading, + error, + } = useQuery({ + queryKey: ['help_requests', { id: id }], + queryFn: () => helpRequestService.getOne(Number(id)), + }); + + if (isLoading) { return (
); } - if (!caso) { + if (error || request === undefined) { return (
@@ -60,7 +56,7 @@ export default function CasoDetalle() { Volver
- +
); }