diff --git a/src/app/casos-activos/ofertas/page.js b/src/app/casos-activos/ofertas/page.js index 3274c5db..d3ff6175 100644 --- a/src/app/casos-activos/ofertas/page.js +++ b/src/app/casos-activos/ofertas/page.js @@ -1,6 +1,6 @@ 'use client'; -import { useState, useEffect } from 'react'; +import { useEffect, useState } from 'react'; import { HeartHandshake } from 'lucide-react'; import { supabase } from '@/lib/supabase/client'; import Pagination from '@/components/Pagination'; @@ -18,7 +18,7 @@ export default function Ofertas() { const [error, setError] = useState(null); const [data, setData] = useState([]); - const [currentPage, setCurrentPage] = useState(1); + const [currentPage, setCurrentPage] = useState(Number(searchParams.get('page')) || 1); const [currentCount, setCurrentCount] = useState(0); const itemsPerPage = 10; @@ -65,7 +65,7 @@ export default function Ofertas() { query.neq('status', 'finished'); // Ejecutar la consulta con paginación - const { data, count, error } = await query + const { data, error } = await query .range((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage - 1) .order('created_at', { ascending: false }); @@ -74,7 +74,7 @@ export default function Ofertas() { setData([]); } else { setData(data || []); - setCurrentCount(count); + setCurrentCount(data.length); } } catch (err) { console.log('Error general:', err); diff --git a/src/app/casos-activos/puntos/page.js b/src/app/casos-activos/puntos/page.js index c5484d49..e3749d81 100644 --- a/src/app/casos-activos/puntos/page.js +++ b/src/app/casos-activos/puntos/page.js @@ -1,7 +1,7 @@ 'use client'; -import { useState, useEffect } from 'react'; -import { MapPin, Phone, Calendar, User, HeartHandshake, Users, Truck, Search, Package, MapPinIcon } from 'lucide-react'; +import { useEffect, useState } from 'react'; +import { HeartHandshake } from 'lucide-react'; import { supabase } from '@/lib/supabase/client'; import { tiposAyudaAcepta } from '@/helpers/constants'; import Pagination from '@/components/Pagination'; @@ -18,7 +18,7 @@ export default function Puntos() { const [error, setError] = useState(null); const [data, setData] = useState([]); - const [currentPage, setCurrentPage] = useState(1); + const [currentPage, setCurrentPage] = useState(Number(searchParams.get('page')) || 1); const [currentCount, setCurrentCount] = useState(0); const [cityOptions, setCityOptions] = useState([]); @@ -56,20 +56,17 @@ export default function Puntos() { try { setError(null); - // Comenzamos la consulta - const query = supabase.from('distinct_collection_cities').select('city'); - - // Ejecutar la consulta - const { data, count, error } = await query; + const { data, error } = await supabase.from('distinct_collection_cities').select('city'); if (error) { console.log('Error fetching ciudades:', error); setCityOptions([]); - } else { - const trimmedCities = data.map((punto) => punto.city?.trim()); - const cities = [...new Set(trimmedCities)].sort(); - setCityOptions(cities || []); - setCurrentCount(count); + return; } + + const trimmedCities = data.map((punto) => punto.city?.trim()); + const cities = [...new Set(trimmedCities)].sort(); + setCityOptions(cities || []); + setCurrentCount(cities.length); } catch (err) { console.log('Error general:', err); setError('Error de conexión.'); @@ -119,7 +116,7 @@ export default function Puntos() { fetchData(); }, [filtroData, currentPage]); - + console.log(currentCount); if (loading) { return (