CheckPoint: Avances Varios
This commit is contained in:
24
frontend/public-web/.gitignore
vendored
Normal file
24
frontend/public-web/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
73
frontend/public-web/README.md
Normal file
73
frontend/public-web/README.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
23
frontend/public-web/eslint.config.js
Normal file
23
frontend/public-web/eslint.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
13
frontend/public-web/index.html
Normal file
13
frontend/public-web/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>public-web</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
4246
frontend/public-web/package-lock.json
generated
Normal file
4246
frontend/public-web/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
40
frontend/public-web/package.json
Normal file
40
frontend/public-web/package.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "public-web",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/postcss": "^4.1.18",
|
||||
"axios": "^1.13.2",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.561.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-router-dom": "^7.11.0",
|
||||
"tailwind-merge": "^3.4.0",
|
||||
"zustand": "^5.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/react": "^19.2.5",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"autoprefixer": "^10.4.23",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"globals": "^16.5.0",
|
||||
"postcss": "^8.5.6",
|
||||
"tailwindcss": "^4.1.18",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.46.4",
|
||||
"vite": "^7.2.4"
|
||||
}
|
||||
}
|
||||
6
frontend/public-web/postcss.config.js
Normal file
6
frontend/public-web/postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
'@tailwindcss/postcss': {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
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[];
|
||||
}
|
||||
24
frontend/public-web/tailwind.config.js
Normal file
24
frontend/public-web/tailwind.config.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: [
|
||||
"./index.html",
|
||||
"./src/**/*.{js,ts,jsx,tsx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
primary: {
|
||||
50: '#f0f9ff',
|
||||
100: '#e0f2fe',
|
||||
500: '#0ea5e9',
|
||||
600: '#0284c7',
|
||||
900: '#0c4a6e',
|
||||
}
|
||||
},
|
||||
fontFamily: {
|
||||
sans: ['Inter', 'sans-serif'],
|
||||
}
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
28
frontend/public-web/tsconfig.app.json
Normal file
28
frontend/public-web/tsconfig.app.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"types": ["vite/client"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
7
frontend/public-web/tsconfig.json
Normal file
7
frontend/public-web/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
26
frontend/public-web/tsconfig.node.json
Normal file
26
frontend/public-web/tsconfig.node.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2023",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
7
frontend/public-web/vite.config.ts
Normal file
7
frontend/public-web/vite.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
Reference in New Issue
Block a user