first commit

This commit is contained in:
2026-02-10 17:51:21 +01:00
parent 079aa1da58
commit db00c3ec89
25 changed files with 1536 additions and 99 deletions

View File

@@ -1,26 +1,56 @@
/* src/app/globals.css */
@import "tailwindcss";
:root {
--background: #ffffff;
--foreground: #171717;
}
@theme {
/* Paleta Surtilatino */
--color-accent: #5D9C59;
--color-dark: #1a1a1a;
--color-light: #f8f8f8;
--color-light-hover: #f0f0f0;
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
}
/* Bordes Boutique */
--radius-huge: 2rem;
@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
/* Animaciones */
--animate-reveal: reveal 0.6s cubic-bezier(0.22, 1, 0.36, 1);
--animate-fade-up: fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
@keyframes reveal {
from { transform: scale(1); }
to { transform: scale(1.08); }
}
@keyframes fade-up {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
--animate-marquee: marquee 25s linear infinite;
@keyframes marquee {
from { transform: translateX(0); }
to { transform: translateX(-50%); }
}
}
body {
background: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
/* Clases utilitarias personalizadas */
@layer utilities {
.text-balance {
text-wrap: balance;
}
/* Ocultar scrollbar pero permitir scroll */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
.no-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
}
}
@layer base {
body {
@apply bg-white text-dark antialiased selection:bg-accent selection:text-white;
}
}

View File

@@ -1,20 +1,22 @@
// src/app/layout.tsx
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { Outfit } from "next/font/google";
import "./globals.css";
import Navbar from "@/components/layout/Navbar";
import CartDrawer from "@/components/layout/CartDrawer";
import Footer from "@/components/layout/Footer";
// (Lo crearemos en el siguiente paso)
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
// Configuración de la fuente Outfit
const outfit = Outfit({
subsets: ["latin"],
variable: "--font-sans", // Vincula con Tailwind
weight: ["200", "300", "400", "500", "600"],
});
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
title: "Surtilatino | Mercado Boutique",
description: "Sabor auténtico, origen natural.",
};
export default function RootLayout({
@@ -23,12 +25,13 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
<html lang="es">
<body className={`${outfit.variable} font-sans`}>
<Navbar />
<CartDrawer />
<main>{children}</main>
<Footer></Footer>
</body>
</html>
);
}
}

View File

@@ -1,65 +1,84 @@
import Image from "next/image";
import { supabase, getProductImageUrl } from "@/lib/supabase";
import Hero from "@/components/sections/Hero";
import ProductCard from "@/components/ui/ProductCard";
import Marquee from "@/components/ui/Marquee";
import { Product } from "@/types";
// Esta función se ejecuta en el SERVIDOR cada vez que alguien entra
async function getProducts() {
const { data, error } = await supabase
.from('products')
.select('*')
.eq('is_active', true) // Solo productos activos
.order('created_at', { ascending: false }) // Los más nuevos primero
.limit(6); // Traemos solo 6 para la home
if (error) {
console.error("Error cargando productos:", error);
return [];
}
return data as Product[];
}
export default async function Home() {
// 1. Obtenemos los datos reales
const products = await getProducts();
export default function Home() {
return (
<div className="flex min-h-screen items-center justify-center bg-zinc-50 font-sans dark:bg-black">
<main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
<Image
className="dark:invert"
src="/next.svg"
alt="Next.js logo"
width={100}
height={20}
priority
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the page.tsx file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Templates
</a>{" "}
or the{" "}
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Learning
</a>{" "}
center.
</p>
<div className="bg-white">
<Hero />
<Marquee />
<section id="shop" className="py-32 px-6 md:px-12 max-w-[1400px] mx-auto">
<div className="flex flex-col md:flex-row justify-between items-end mb-16 gap-4">
<h2 className="text-3xl md:text-4xl font-light leading-tight">
Favoritos <br /> de la semana.
</h2>
<div className="text-right">
<p className="text-xs text-gray-400 mb-2 uppercase tracking-widest">
{products.length} productos disponibles
</p>
<a href="/shop" className="text-sm border-b border-gray-300 pb-1 hover:border-dark hover:text-dark transition text-gray-500">
Ver catálogo completo
</a>
</div>
</div>
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
<a
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert"
src="/vercel.svg"
alt="Vercel logomark"
width={16}
height={16}
/>
Deploy Now
</a>
<a
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Documentation
</a>
{/* Grid de Productos */}
{products.length > 0 ? (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-16">
{products.map((product, index) => (
<ProductCard
key={product.id}
id={product.id}
title={product.name}
category={product.category || "General"}
price={product.price}
imageUrl={getProductImageUrl(product.image_url)}
index={index + 1}
/>
))}
</div>
) : (
/* Estado Vacío (Empty State) Minimalista */
<div className="text-center py-20 bg-light rounded-[2rem]">
<p className="text-gray-400 font-light text-lg">Aún no hemos subido productos.</p>
<p className="text-sm text-gray-300 mt-2">Vuelve pronto para ver nuestras novedades.</p>
</div>
)}
</section>
{/* Frase Editorial */}
<section className="py-24 px-6 bg-[#f8f8f8] mb-20">
<div className="max-w-3xl mx-auto text-center">
<h3 className="text-2xl md:text-3xl font-light leading-relaxed mb-6">
"No vendemos solo ingredientes. Vendemos la <span className="text-gray-400 line-through decoration-1 opacity-50">nostalgia</span> alegría de cocinar como en casa."
</h3>
<p className="text-xs text-gray-500 uppercase tracking-widest font-semibold">Familia Mercado, desde 2010</p>
</div>
</main>
</section>
</div>
);
}
}

View File

@@ -0,0 +1,149 @@
// src/app/product/[id]/page.tsx
import { notFound } from "next/navigation";
import Link from "next/link";
import { ArrowLeft, Truck, ShieldCheck } from "lucide-react";
import { supabase, getProductImageUrl } from "@/lib/supabase";
import { Product } from "@/types";
import ProductCard from "@/components/ui/ProductCard";
import ProductActions from "@/components/product/ProductActions";
// 1. Función para obtener el producto actual
async function getProduct(id: string) {
const { data, error } = await supabase
.from('products')
.select('*')
.eq('id', id)
.single();
if (error || !data) return null;
return data as Product;
}
// 2. Función para obtener productos relacionados
async function getRelatedProducts(category: string, currentId: string) {
const { data } = await supabase
.from('products')
.select('*')
.eq('category', category)
.neq('id', currentId)
.eq('is_active', true)
.limit(3);
return (data as Product[]) || [];
}
// 3. DEFINICIÓN DEL COMPONENTE (Aquí estaba el error de tipos)
// En lugar de una interfaz separada, tipamos inline para evitar conflictos con Next.js 15
export default async function ProductPage(props: {
params: Promise<{ id: string }>
}) {
// Await obligatorio en Next.js 15 antes de acceder a params
const params = await props.params;
const { id } = params;
const product = await getProduct(id);
if (!product) {
notFound();
}
const relatedProducts = await getRelatedProducts(product.category, product.id);
const imageUrl = getProductImageUrl(product.image_url);
return (
<div className="bg-white min-h-screen pb-32">
{/* Navegación Breadcrumb */}
<div className="pt-32 px-6 md:px-12 max-w-[1400px] mx-auto mb-8">
<Link href="/" className="inline-flex items-center gap-2 text-sm text-gray-400 hover:text-dark transition-colors">
<ArrowLeft className="w-4 h-4" />
Volver al catálogo
</Link>
</div>
<main className="px-6 md:px-12 max-w-[1400px] mx-auto">
<div className="grid grid-cols-1 lg:grid-cols-2 gap-12 lg:gap-24">
{/* COLUMNA IZQUIERDA: Imagen Heroica */}
<div className="relative">
<div className="bg-[#f8f8f8] rounded-[2rem] aspect-[4/5] flex items-center justify-center overflow-hidden sticky top-32">
<img
src={imageUrl}
alt={product.name}
className="w-3/4 h-3/4 object-contain drop-shadow-2xl transition-transform duration-700 hover:scale-105"
/>
{/* Badge de Stock */}
{product.stock < 5 && product.stock > 0 && (
<span className="absolute top-8 left-8 bg-red-50 text-red-500 px-4 py-1 rounded-full text-xs font-semibold tracking-wide uppercase">
Últimas {product.stock} unidades
</span>
)}
</div>
</div>
{/* COLUMNA DERECHA: Detalles */}
<div className="flex flex-col justify-center lg:py-12">
<span className="text-accent text-sm tracking-[0.2em] uppercase font-medium mb-4 block">
{product.category}
</span>
<h1 className="text-5xl md:text-6xl font-light text-dark mb-6 leading-[1.1] tracking-tight">
{product.name}
</h1>
<div className="flex items-center gap-6 mb-8 border-b border-gray-100 pb-8">
<span className="text-3xl font-medium text-dark">
{new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR' }).format(product.price)}
</span>
{product.stock > 0 ? (
<span className="text-green-600 text-sm flex items-center gap-1">
<span className="w-2 h-2 bg-green-500 rounded-full animate-pulse"></span>
En Stock
</span>
) : (
<span className="text-gray-400 text-sm">Agotado</span>
)}
</div>
<div className="prose prose-neutral max-w-none text-gray-500 font-light leading-relaxed mb-12">
<p>{product.description || "Sin descripción disponible para este producto."}</p>
</div>
{/* Componente Interactivo */}
<ProductActions product={product} />
<div className="grid grid-cols-2 gap-4 text-xs text-gray-400 uppercase tracking-wider font-medium">
<div className="flex items-center gap-3">
<Truck className="w-5 h-5 text-dark" />
<span>Envío en 24/48h</span>
</div>
<div className="flex items-center gap-3">
<ShieldCheck className="w-5 h-5 text-dark" />
<span>Calidad Garantizada</span>
</div>
</div>
</div>
</div>
{/* Relacionados */}
{relatedProducts.length > 0 && (
<section className="mt-32 border-t border-gray-100 pt-20">
<h2 className="text-2xl font-light mb-12">También te podría gustar</h2>
<div className="grid grid-cols-1 md:grid-cols-3 gap-x-8 gap-y-16">
{relatedProducts.map((prod, idx) => (
<ProductCard
key={prod.id}
id={prod.id}
title={prod.name}
category={prod.category}
price={prod.price}
imageUrl={getProductImageUrl(prod.image_url)}
index={idx + 1}
/>
))}
</div>
</section>
)}
</main>
</div>
);
}

52
src/app/shop/page.tsx Normal file
View File

@@ -0,0 +1,52 @@
// src/app/shop/page.tsx
import { supabase } from "@/lib/supabase";
import { Product, Category } from "@/types";
import CatalogBrowser from "@/components/shop/CatalogBrowser";
export const revalidate = 0; // Datos siempre frescos
// 1. Tu función para traer categorías
async function getCategories() {
const { data, error } = await supabase
.from('categories')
.select('*')
.order('name', { ascending: true });
if (error) {
console.error('Error cargando categorías:', error.message);
return [];
}
return data as Category[];
}
// 2. Función para traer productos
async function getAllProducts() {
const { data, error } = await supabase
.from('products')
.select('*')
.eq('is_active', true)
.order('created_at', { ascending: false });
if (error) {
console.error("Error fetching shop products:", error);
return [];
}
return data as Product[];
}
export default async function ShopPage() {
// 3. Ejecutamos ambas peticiones a la vez (Parallel Data Fetching)
const [products, categories] = await Promise.all([
getAllProducts(),
getCategories()
]);
return (
<div className="bg-white min-h-screen">
{/* Pasamos ambas listas al componente cliente */}
<CatalogBrowser initialProducts={products} categories={categories} />
</div>
);
}