CheckPoint: Avances Varios
This commit is contained in:
42
frontend/public-web/src/App.css
Normal file
42
frontend/public-web/src/App.css
Normal file
@@ -0,0 +1,42 @@
|
||||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
42
frontend/public-web/src/App.tsx
Normal file
42
frontend/public-web/src/App.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||
import HomePage from './pages/HomePage';
|
||||
import ListingDetailPage from './pages/ListingDetailPage';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<div className="flex flex-col min-h-screen">
|
||||
<header className="bg-white border-b border-gray-100 py-4 px-6 sticky top-0 z-50">
|
||||
<div className="max-w-6xl mx-auto flex items-center justify-between">
|
||||
<a href="/" className="font-bold text-2xl text-primary-600">SIG-CM</a>
|
||||
<nav className="hidden md:flex gap-6 text-sm font-medium text-gray-600">
|
||||
<a href="/" className="hover:text-primary-600">Inicio</a>
|
||||
<a href="#" className="hover:text-primary-600">Categorías</a>
|
||||
</nav>
|
||||
<div>
|
||||
<a
|
||||
href="http://localhost:5174"
|
||||
className="bg-primary-600 text-white px-5 py-2 rounded-full font-medium hover:bg-primary-700 transition"
|
||||
>
|
||||
Publicar Aviso
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Routes>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
<Route path="/listing/:id" element={<ListingDetailPage />} />
|
||||
</Routes>
|
||||
|
||||
<footer className="bg-gray-900 text-gray-400 py-12 mt-auto">
|
||||
<div className="max-w-6xl mx-auto px-4 text-center">
|
||||
<p>© 2024 SIG-CM Clasificados Multicanal.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
45
frontend/public-web/src/components/ListingCard.tsx
Normal file
45
frontend/public-web/src/components/ListingCard.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { Listing } from '../types';
|
||||
import { MapPin } from 'lucide-react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
export default function ListingCard({ listing }: { listing: Listing }) {
|
||||
const baseUrl = import.meta.env.VITE_BASE_URL;
|
||||
|
||||
// Lógica de imagen: Si viene del backend, la usamos. Si no, placeholder local o remoto.
|
||||
const imageUrl = listing.mainImageUrl
|
||||
? `${baseUrl}${listing.mainImageUrl}`
|
||||
: 'https://placehold.co/400x300?text=Sin+Foto'; // placehold.co es más rápido y fiable que via.placeholder
|
||||
|
||||
return (
|
||||
<Link to={`/listing/${listing.id}`} className="block h-full">
|
||||
<div className="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden hover:shadow-md transition group h-full flex flex-col">
|
||||
<div className="aspect-[4/3] bg-gray-100 relative overflow-hidden">
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt={listing.title}
|
||||
className="w-full h-full object-cover group-hover:scale-105 transition duration-500"
|
||||
onError={(e) => {
|
||||
// Fallback si la imagen falla al cargar
|
||||
e.currentTarget.src = 'https://placehold.co/400x300?text=Error+Carga';
|
||||
}}
|
||||
/>
|
||||
<div className="absolute top-3 right-3 bg-white/90 backdrop-blur px-2 py-1 rounded text-xs font-bold uppercase tracking-wide">
|
||||
Ver
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-4 flex flex-col flex-grow">
|
||||
<div className="text-2xl font-bold text-gray-900 mb-1">
|
||||
{listing.currency} {listing.price.toLocaleString()}
|
||||
</div>
|
||||
<h3 className="font-medium text-gray-800 mb-2 line-clamp-2 group-hover:text-primary-600 transition">
|
||||
{listing.title}
|
||||
</h3>
|
||||
<div className="mt-auto pt-4 border-t border-gray-100 flex items-center text-sm text-gray-500">
|
||||
<MapPin size={16} className="mr-1" />
|
||||
<span>Ver detalles</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
35
frontend/public-web/src/components/SearchBar.tsx
Normal file
35
frontend/public-web/src/components/SearchBar.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Search } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
|
||||
interface SearchBarProps {
|
||||
onSearch?: (query: string) => void;
|
||||
}
|
||||
|
||||
export default function SearchBar({ onSearch }: SearchBarProps) {
|
||||
const [query, setQuery] = useState('');
|
||||
|
||||
const handleSearch = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (onSearch) {
|
||||
onSearch(query);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSearch} className="w-full max-w-2xl relative">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="¿Qué estás buscando? (Ej: Departamento, Fiat 600...)"
|
||||
className="w-full py-4 pl-6 pr-14 rounded-full border border-gray-200 shadow-lg text-gray-800 text-lg focus:outline-none focus:ring-2 focus:ring-primary-500 transition-all placeholder:text-gray-400"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="absolute right-2 top-2 p-2 bg-primary-600 text-white rounded-full hover:bg-primary-700 transition flex items-center justify-center w-10 h-10"
|
||||
>
|
||||
<Search size={20} />
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
17
frontend/public-web/src/index.css
Normal file
17
frontend/public-web/src/index.css
Normal file
@@ -0,0 +1,17 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
||||
|
||||
@theme {
|
||||
--font-sans: 'Inter', sans-serif;
|
||||
--color-primary-50: #f0f9ff;
|
||||
--color-primary-100: #e0f2fe;
|
||||
--color-primary-500: #0ea5e9;
|
||||
--color-primary-600: #0284c7;
|
||||
--color-primary-900: #0c4a6e;
|
||||
}
|
||||
|
||||
body {
|
||||
/* En v4 @apply funciona, pero requiere que el import esté arriba */
|
||||
@apply bg-gray-50 text-gray-900 font-sans;
|
||||
}
|
||||
10
frontend/public-web/src/main.tsx
Normal file
10
frontend/public-web/src/main.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.tsx'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
94
frontend/public-web/src/pages/HomePage.tsx
Normal file
94
frontend/public-web/src/pages/HomePage.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import SearchBar from '../components/SearchBar';
|
||||
import ListingCard from '../components/ListingCard';
|
||||
import { publicService } from '../services/publicService';
|
||||
import type { Listing, Category } from '../types';
|
||||
|
||||
export default function HomePage() {
|
||||
const [listings, setListings] = useState<Listing[]>([]);
|
||||
const [categories, setCategories] = useState<Category[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
loadInitialData();
|
||||
}, []);
|
||||
|
||||
const loadInitialData = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const [latestListings, cats] = await Promise.all([
|
||||
publicService.getLatestListings(),
|
||||
publicService.getCategories()
|
||||
]);
|
||||
setListings(latestListings);
|
||||
setCategories(cats);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSearch = async (query: string) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const results = await publicService.searchListings(query);
|
||||
setListings(results);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const mainCategories = categories.filter(c => !c.parentId);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 pb-20">
|
||||
{/* Hero Section */}
|
||||
<div className="bg-primary-900 text-white py-20 px-4 relative overflow-hidden">
|
||||
<div className="absolute inset-0 bg-gradient-to-br from-primary-900 to-gray-900 opacity-90"></div>
|
||||
<div className="max-w-4xl mx-auto text-center relative z-10">
|
||||
<h1 className="text-4xl md:text-5xl font-bold mb-6">Encuentra tu próximo objetivo</h1>
|
||||
<p className="text-xl text-primary-100 mb-10">Clasificados verificados de Autos, Propiedades y más.</p>
|
||||
<div className="flex justify-center">
|
||||
<SearchBar onSearch={handleSearch} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Categories Quick Links */}
|
||||
<div className="max-w-6xl mx-auto px-4 -mt-8 relative z-20">
|
||||
<div className="bg-white rounded-xl shadow-lg p-6 flex flex-wrap justify-center gap-4 md:gap-8 border border-gray-100">
|
||||
{mainCategories.map(cat => (
|
||||
<button key={cat.id} className="flex flex-col items-center gap-2 group">
|
||||
<div className="w-12 h-12 rounded-full bg-primary-50 flex items-center justify-center text-primary-600 group-hover:bg-primary-600 group-hover:text-white transition">
|
||||
<div className="font-bold text-lg">{cat.name.charAt(0)}</div>
|
||||
</div>
|
||||
<span className="text-sm font-medium text-gray-600 group-hover:text-primary-700">{cat.name}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Latest Listings */}
|
||||
<div className="max-w-6xl mx-auto px-4 mt-16">
|
||||
<h2 className="text-2xl font-bold text-gray-900 mb-8">
|
||||
{loading ? 'Cargando...' : 'Resultados Recientes'}
|
||||
</h2>
|
||||
|
||||
{!loading && listings.length === 0 && (
|
||||
<div className="text-center text-gray-500 py-10">
|
||||
No se encontraron avisos con esos criterios.
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
{listings.map(listing => (
|
||||
<ListingCard key={listing.id} listing={listing} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
118
frontend/public-web/src/pages/ListingDetailPage.tsx
Normal file
118
frontend/public-web/src/pages/ListingDetailPage.tsx
Normal file
@@ -0,0 +1,118 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { publicService } from '../services/publicService';
|
||||
import type { ListingDetail } from '../types';
|
||||
import { Calendar, Tag, ChevronLeft } from 'lucide-react';
|
||||
|
||||
export default function ListingDetailPage() {
|
||||
const { id } = useParams();
|
||||
const [detail, setDetail] = useState<ListingDetail | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [activeImage, setActiveImage] = useState<string>('');
|
||||
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
publicService.getListingDetail(parseInt(id))
|
||||
.then(data => {
|
||||
setDetail(data);
|
||||
if (data.images.length > 0) {
|
||||
setActiveImage(data.images[0].url);
|
||||
}
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
.finally(() => setLoading(false));
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
if (loading) return <div className="min-h-screen flex items-center justify-center">Cargando...</div>;
|
||||
if (!detail) return <div className="min-h-screen flex items-center justify-center">Aviso no encontrado.</div>;
|
||||
|
||||
const { listing, attributes, images } = detail;
|
||||
const baseUrl = import.meta.env.VITE_BASE_URL; // Ajustar puerto según backend launchSettings
|
||||
|
||||
return (
|
||||
<div className="max-w-6xl mx-auto px-4 py-8">
|
||||
<a href="/" className="inline-flex items-center text-gray-500 hover:text-primary-600 mb-6">
|
||||
<ChevronLeft size={20} /> Volver al listado
|
||||
</a>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
||||
{/* Galería de Fotos */}
|
||||
<div className="lg:col-span-2 space-y-4">
|
||||
<div className="aspect-video bg-gray-100 rounded-xl overflow-hidden border border-gray-200">
|
||||
{activeImage ? (
|
||||
<img src={`${baseUrl}${activeImage}`} alt={listing.title} className="w-full h-full object-contain" />
|
||||
) : (
|
||||
<div className="w-full h-full flex items-center justify-center text-gray-400">Sin imágenes</div>
|
||||
)}
|
||||
</div>
|
||||
{images.length > 1 && (
|
||||
<div className="flex gap-2 overflow-x-auto pb-2">
|
||||
{images.map(img => (
|
||||
<button
|
||||
key={img.id}
|
||||
onClick={() => setActiveImage(img.url)}
|
||||
className={`w-24 h-24 flex-shrink-0 rounded-lg overflow-hidden border-2 transition ${activeImage === img.url ? 'border-primary-600' : 'border-transparent'
|
||||
}`}
|
||||
>
|
||||
<img src={`${baseUrl}${img.url}`} alt="" className="w-full h-full object-cover" />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Información Principal */}
|
||||
<div className="space-y-6">
|
||||
<div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
|
||||
<div className="flex justify-between items-start mb-4">
|
||||
<span className="bg-primary-50 text-primary-700 px-3 py-1 rounded-full text-sm font-medium">
|
||||
Clasificado #{listing.id}
|
||||
</span>
|
||||
<span className="text-gray-400 text-sm flex items-center gap-1">
|
||||
<Calendar size={14} />
|
||||
{new Date(listing.createdAt).toLocaleDateString()}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 className="text-3xl font-bold text-gray-900 mb-2">{listing.title}</h1>
|
||||
<div className="text-4xl font-bold text-primary-600 mb-6">
|
||||
{listing.currency} {listing.price.toLocaleString()}
|
||||
</div>
|
||||
|
||||
<button className="w-full bg-green-600 hover:bg-green-700 text-white font-bold py-3 rounded-lg transition mb-4">
|
||||
Contactar Anunciante
|
||||
</button>
|
||||
<button className="w-full bg-white border border-gray-300 text-gray-700 font-bold py-3 rounded-lg hover:bg-gray-50 transition">
|
||||
Compartir
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Atributos Dinámicos */}
|
||||
<div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
|
||||
<h3 className="text-lg font-semibold mb-4 flex items-center gap-2">
|
||||
<Tag size={20} className="text-primary-600" />
|
||||
Características
|
||||
</h3>
|
||||
<div className="grid grid-cols-2 gap-y-4 gap-x-2">
|
||||
{attributes.map(attr => (
|
||||
<div key={attr.id} className="border-b border-gray-50 pb-2">
|
||||
<span className="block text-xs text-gray-500 uppercase tracking-wide">{attr.attributeName}</span>
|
||||
<span className="font-medium text-gray-800">{attr.value}</span>
|
||||
</div>
|
||||
))}
|
||||
{attributes.length === 0 && <p className="text-gray-400 text-sm">Sin características adicionales.</p>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
|
||||
<h3 className="text-lg font-semibold mb-2">Descripción</h3>
|
||||
<p className="text-gray-600 leading-relaxed whitespace-pre-line">
|
||||
{listing.description || "Sin descripción proporcionada."}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
7
frontend/public-web/src/services/api.ts
Normal file
7
frontend/public-web/src/services/api.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_URL, // Usa la variable de entorno
|
||||
});
|
||||
|
||||
export default api;
|
||||
26
frontend/public-web/src/services/publicService.ts
Normal file
26
frontend/public-web/src/services/publicService.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import api from './api';
|
||||
import type { Listing, Category, ListingDetail } from '../types';
|
||||
|
||||
export const publicService = {
|
||||
getLatestListings: async (): Promise<Listing[]> => {
|
||||
const response = await api.get<Listing[]>('/listings');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
searchListings: async (query: string): Promise<Listing[]> => {
|
||||
const response = await api.get<Listing[]>('/listings', {
|
||||
params: { q: query }
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getListingDetail: async (id: number): Promise<ListingDetail> => {
|
||||
const response = await api.get<ListingDetail>(`/listings/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getCategories: async (): Promise<Category[]> => {
|
||||
const response = await api.get<Category[]>('/categories');
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
41
frontend/public-web/src/types/index.ts
Normal file
41
frontend/public-web/src/types/index.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
export interface Listing {
|
||||
id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
price: number;
|
||||
currency: string;
|
||||
categoryId: number;
|
||||
operationId: number;
|
||||
createdAt: string;
|
||||
mainImageUrl?: string;
|
||||
images?: ListingImage[];
|
||||
}
|
||||
|
||||
export interface ListingAttribute {
|
||||
id: number;
|
||||
listingId: number;
|
||||
attributeDefinitionId: number;
|
||||
value: string;
|
||||
attributeName: string;
|
||||
}
|
||||
|
||||
export interface ListingImage {
|
||||
id: number;
|
||||
listingId: number;
|
||||
url: string;
|
||||
isMainInfo: boolean;
|
||||
displayOrder: number;
|
||||
}
|
||||
|
||||
export interface ListingDetail {
|
||||
listing: Listing;
|
||||
attributes: ListingAttribute[];
|
||||
images: ListingImage[];
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: number;
|
||||
name: string;
|
||||
parentId?: number;
|
||||
subcategories?: Category[];
|
||||
}
|
||||
Reference in New Issue
Block a user