Skip to content

Commit

Permalink
Merge pull request #88 from pedrolivaresanchez/feature/remove-location
Browse files Browse the repository at this point in the history
feature: on change state to finished, hidden card & remove location f…
  • Loading branch information
vsornosa1 authored Nov 6, 2024
2 parents b26116a + 0483150 commit 52f0c6a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/app/casos-activos/ofertas/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default function Ofertas() {
query.contains('help_type', [filtroData.ayuda]);
}

query.neq('status', 'finished');
// Ejecutar la consulta con paginación
const { data, count, error } = await query
.range((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage - 1)
Expand Down Expand Up @@ -140,7 +141,7 @@ export default function Ofertas() {
</button>
</div>
) : (
data.map((caso) => <OfferCard caso={caso} isHref={true} key={caso.id} />)
data.map((caso) => <OfferCard caso={caso} towns={towns} isHref={true} key={caso.id} />)
)}
</div>
<div className="flex items-center justify-center">
Expand Down
2 changes: 1 addition & 1 deletion src/app/casos-activos/solicitudes/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function Solicitudes() {
if (filtroData.urgencia !== 'todas') {
query.eq('urgency', filtroData.urgencia);
}

query.neq('status', 'finished');
// Ejecutar la consulta con paginación
const { data, count, error } = await query
.range((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage - 1)
Expand Down
4 changes: 3 additions & 1 deletion src/app/oferta/[id]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { useParams } from 'next/navigation';
import { supabase } from '@/lib/supabase/client';
import { ArrowLeft } from 'lucide-react';
import OfferCard from '../../../components/OfferCard';
import { useTowns } from '../../../context/TownProvider';

export default function CasoDetalle() {
const params = useParams();
const { id } = params;
const [caso, setCaso] = useState(null);
const [loading, setLoading] = useState(true);
const towns = useTowns();
useEffect(() => {
async function fetchCaso() {
const { data, error } = await supabase.from('help_requests').select('*').eq('id', id).single();
Expand Down Expand Up @@ -58,7 +60,7 @@ export default function CasoDetalle() {
Volver
</button>
</div>
<OfferCard key={caso.id} caso={caso} />
<OfferCard towns={towns} key={caso.id} caso={caso} />
</div>
);
}
1 change: 1 addition & 0 deletions src/app/ofertas/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export default function ListaSolicitudes() {
caso={caso}
button={{ text: 'Editar', link: '/ofertas/editar/' }}
isEdit={true}
towns={towns}
/>
))
)}
Expand Down
26 changes: 20 additions & 6 deletions src/components/OfferCard.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Calendar, HeartHandshake, MapPin, Phone, Truck, User } from 'lucide-react';
import { Calendar, HeartHandshake, MapPin, MapPinned, Phone, Truck, User } from 'lucide-react';
import { useSession } from '../context/SessionProvider';
import { tiposAyudaOptions } from '@/helpers/constants';
import Link from 'next/link';

export default function OfferCard({ caso, isHref, button = { text: 'Ver oferta', link: '/oferta/' }, isEdit = false }) {
export default function OfferCard({
caso,
isHref,
towns,
button = { text: 'Ver oferta', link: '/oferta/' },
isEdit = false,
}) {
const session = useSession();
return (
<div key={caso.id} className="bg-white p-4 rounded-lg shadow-lg border-l-4 border-green-500 overflow-hidden">
Expand All @@ -24,7 +30,7 @@ export default function OfferCard({ caso, isHref, button = { text: 'Ver oferta',
</span>
</div>

<div className="space-y-2 mb-4">
<div className="space-y-2 mb-1">
<h3 className="text-lg font-bold text-green-600">
<div className="flex items-start gap-2">
<HeartHandshake className="h-5 w-5 flex-shrink-0 mt-1" />
Expand Down Expand Up @@ -82,16 +88,24 @@ export default function OfferCard({ caso, isHref, button = { text: 'Ver oferta',
})()}
</>
)}

{caso.location && (
{/* VOLUNTARIOS NO QUIEREN MOSTRAR SU DIRECCION */}
{/* {caso.location && (
<div className="flex items-start gap-2">
<MapPin className="h-4 w-4 text-gray-500 flex-shrink-0 mt-1" />
<span className="break-words">
<span className="font-semibold">Ubicación:</span> {caso.location}
</span>
</div>
)}
)} */}

{caso.town_id && (
<div className="flex items-start gap-2">
<MapPinned className="h-4 w-4 text-gray-500 flex-shrink-0 mt-1" />
<span className="break-words">
<span className="font-semibold">Pueblo:</span> {towns[caso.town_id - 1].name || ''}
</span>
</div>
)}
<div className="flex items-start gap-2">
<Calendar className="h-4 w-4 text-gray-500 flex-shrink-0 mt-1" />
<span className="break-words">
Expand Down

0 comments on commit 52f0c6a

Please sign in to comment.