Compare commits

...
Author SHA1 Message Date
devops 7a67ba0743 feat(ecommerce): tiles promocionales intercalados en el grid del catalogo
Build and Push Frontend / Escaneo de Secretos (Gitleaks) (pull_request) Successful in 23s
Build and Push Frontend / Construir y Subir Imagen (pull_request) Skipped
ADR 0005 seccion 3 (patron Walmart), ultimo item de la sub-fase de
componentes visuales: "grid de catalogo con tiles promocionales
intercalados, no solo tarjetas de producto homogeneas".

`category-tiles.tsx` ya era ese mismo primitivo visual (usado en el
home) -- se extrajo el tile individual a un componente exportado
`PromoTile` (mismo look, sin cambio visual en el home) para
reutilizarlo en `catalog-client.tsx`: un tile cada
PROMO_TILE_INTERVAL=8 productos, ciclando por las categorias raiz
(excluye la raiz que el usuario ya esta viendo via el breadcrumb de
#40). Si no hay jerarquia de categorias disponible, la grilla queda
igual que antes (solo productos) -- degradacion sin romper nada.

Depende de #40 (breadcrumb + categoryNodes en CatalogClient) -- mismo
archivo, se apila sobre esa rama en vez de main.
2026-08-25 14:40:52 -05:00
devops bc566b1fc0 feat(ecommerce): breadcrumb real + conteos por filtro en el catalogo
Build and Push Frontend / Escaneo de Secretos (Gitleaks) (pull_request) Successful in 2m32s
Build and Push Frontend / Construir y Subir Imagen (pull_request) Skipped
ADR 0005 seccion 3 (patron Amazon), primer item de "Filtros facetados
en sidebar con breadcrumb de categoria":

- Breadcrumb (Inicio > raiz > hija) armado caminando parentId sobre la
  jerarquia real de categorias (misma que ya consume el mega-menu de
  navbar.tsx), no un dato nuevo -- CatalogClient ahora recibe el
  arreglo `categories: Category[]` completo ademas del
  `categoryGroups` ya existente
- Conteo por valor en cada filtro de la sidebar (Categoria/Marca/Edad),
  ej. "Marca (12)": se calcula client-side sobre los productos que ya
  pasan el resto de filtros activos, cada dimension excluyendose a si
  misma (patron faceted-count estandar). Sin Meilisearch por ahora,
  como preveia el ADR ("server-side simple por ahora")

Filtrado existente refactorizado a funciones matchesX() puras y
reutilizadas tanto por `filtered` como por los conteos, sin cambiar el
comportamiento de filtrado ya validado.
2026-08-25 14:37:29 -05:00
devops 707a05cc6e Merge pull request 'fix(ecommerce): selector de variante inline en tarjeta de producto' (#38) from fix/etapa2-subfase3-swatches-inline into main
Build and Push Frontend / Escaneo de Secretos (Gitleaks) (push) Successful in 25s
Build and Push Frontend / Construir y Subir Imagen (push) Successful in 10m37s
2026-08-25 19:31:15 +00:00
devops e20f3e1ddf feat(ecommerce): selector de variante inline en tarjeta de producto
Build and Push Frontend / Escaneo de Secretos (Gitleaks) (pull_request) Successful in 39s
Build and Push Frontend / Construir y Subir Imagen (pull_request) Skipped
Reutiliza Product.variants[].{name,value,available}, ya expuesto por el
provider de Medusa (variant.options[0]), para swatches clicables en la
tarjeta del catalogo/home -- no solo en la ficha de producto. Solo se
muestra cuando el producto tiene mas de una variante; la variante
seleccionada se usa al agregar al carrito. ADR 0005 seccion 3 (patron
eBay), cero cambio de modelo de datos.
2026-08-25 14:29:50 -05:00
devops 5b03066ed2 chore: release v1.0.147 [skip ci] 2026-08-25 19:24:43 +00:00
devops 78cc5ef93b Merge pull request 'fix(ecommerce): badge antes/ahora en tarjetas de producto' (#37) from fix/etapa2-subfase3-badges-antes-ahora into main
Build and Push Frontend / Escaneo de Secretos (Gitleaks) (push) Successful in 31s
Build and Push Frontend / Construir y Subir Imagen (push) Successful in 11m41s
2026-08-25 19:12:37 +00:00
devops 9a8e12fa8b feat(ecommerce): badge antes/ahora en tarjetas de producto
Build and Push Frontend / Escaneo de Secretos (Gitleaks) (pull_request) Successful in 22s
Build and Push Frontend / Construir y Subir Imagen (pull_request) Skipped
Reutiliza Product.compareAtPrice (ya calculado en el provider de Medusa
via original_amount > calculated_amount) para mostrar precio tachado +
badge de descuento en la grilla/catalogo, no solo en la ficha de
producto. ADR 0005 seccion 3, patron Walmart -- cero cambio de modelo
de datos.
2026-08-25 14:10:33 -05:00
devops e36525e0d8 chore: release v1.0.145 [skip ci] 2026-08-25 19:05:55 +00:00
devops b00dd14f76 Merge pull request 'fix(ecommerce): mega-menu de Departamentos multi-columna en el navbar' (#36) from fix/etapa2-subfase3-visuales into main
Build and Push Frontend / Escaneo de Secretos (Gitleaks) (push) Successful in 28s
Build and Push Frontend / Construir y Subir Imagen (push) Successful in 15m21s
2026-08-25 18:50:11 +00:00
5 changed files with 243 additions and 56 deletions

No files matched your search

+1
View File
@@ -41,6 +41,7 @@ export default async function CatalogPage({ searchParams }: CatalogPageProps) {
<CatalogClient <CatalogClient
key={`${category}:${collection}:${query}`} key={`${category}:${collection}:${query}`}
products={products} products={products}
categories={categories}
categoryGroups={categoryGroups} categoryGroups={categoryGroups}
initialCategory={category} initialCategory={category}
initialCollection={collection} initialCollection={collection}
@@ -1,22 +1,70 @@
"use client"; "use client";
import { SlidersHorizontal, X } from "lucide-react"; import Link from "next/link";
import { ChevronRight, SlidersHorizontal, X } from "lucide-react";
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { PromoTile } from "@/components/home/category-tiles";
import { ProductCard } from "@/components/product/product-card"; import { ProductCard } from "@/components/product/product-card";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import type { Product } from "@/lib/headless/types"; import type { Category, Product } from "@/lib/headless/types";
// Cada cuantas tarjetas de producto se intercala un tile promocional en
// la grilla (patron Walmart, ADR 0005 seccion 3): grid con tiles
// promocionales intercalados, no solo tarjetas homogeneas.
const PROMO_TILE_INTERVAL = 8;
type GridItem = { type: "product"; product: Product } | { type: "promo"; category: Category };
type CatalogClientProps = { type CatalogClientProps = {
products: Product[]; products: Product[];
categories?: Category[];
categoryGroups?: Record<string, string[]>; categoryGroups?: Record<string, string[]>;
initialCategory?: string; initialCategory?: string;
initialCollection?: string; initialCollection?: string;
initialQuery?: string; initialQuery?: string;
}; };
function matchesQuery(product: Product, query: string): boolean {
if (!query) return true;
const search = [product.name, product.category, product.collection, product.brand].join(" ").toLowerCase();
return search.includes(query.toLowerCase());
}
function matchesCategory(product: Product, allowedCategories: string[]): boolean {
return allowedCategories.includes(product.category);
}
function matchesCollection(product: Product, collection: string): boolean {
return !collection || product.collection === collection;
}
function matchesBrand(product: Product, brand: string): boolean {
return brand === "Todas" || product.brand === brand;
}
function matchesAge(product: Product, age: string): boolean {
return age === "Todas" || product.ageRange === age;
}
function matchesPrice(product: Product, maxPrice: number): boolean {
return product.price === null || maxPrice === 0 || product.price <= maxPrice;
}
// Camina parentId hacia arriba desde la categoria seleccionada para armar
// el breadcrumb real (Inicio > raiz > hija), igual que en Amazon.
function buildBreadcrumb(categories: Category[], name: string): Category[] {
const node = categories.find((category) => category.name === name);
if (!node) return [];
const trail = [node];
let current = node;
while (current.parentId) {
const parent = categories.find((category) => category.id === current.parentId);
if (!parent) break;
trail.unshift(parent);
current = parent;
}
return trail;
}
export function CatalogClient({ export function CatalogClient({
products, products,
categories: categoryNodes = [],
categoryGroups = {}, categoryGroups = {},
initialCategory = "Todos", initialCategory = "Todos",
initialCollection = "", initialCollection = "",
@@ -55,29 +103,25 @@ export function CatalogClient({
// tiene la raiz asignada directamente. Si no es una raiz conocida, se // tiene la raiz asignada directamente. Si no es una raiz conocida, se
// trata como el nombre de categoria exacto de siempre. // trata como el nombre de categoria exacto de siempre.
const allowedCategories = categoryGroups[category] ?? [category]; const allowedCategories = categoryGroups[category] ?? [category];
const breadcrumb = useMemo(() => (category === "Todos" ? [] : buildBreadcrumb(categoryNodes, category)), [categoryNodes, category]);
// No promociona la misma categoria raiz que el usuario ya esta viendo.
const promoRoots = useMemo(() => {
const excludeRootId = breadcrumb[0]?.id;
return categoryNodes.filter((node) => !node.parentId && node.id !== excludeRootId);
}, [categoryNodes, breadcrumb]);
const filtered = useMemo( const filtered = useMemo(
() => () =>
products products
.filter((product) => { .filter(
const search = [ (product) =>
product.name, matchesQuery(product, query) &&
product.category, (category === "Todos" || matchesCategory(product, allowedCategories)) &&
product.collection, matchesCollection(product, collection) &&
product.brand, matchesBrand(product, brand) &&
] matchesAge(product, age) &&
.join(" ") matchesPrice(product, maxPrice),
.toLowerCase(); )
return (
(!query || search.includes(query.toLowerCase())) &&
(category === "Todos" || allowedCategories.includes(product.category)) &&
(!collection || product.collection === collection) &&
(brand === "Todas" || product.brand === brand) &&
(age === "Todas" || product.ageRange === age) &&
(product.price === null || maxPrice === 0 || product.price <= maxPrice)
);
})
.sort((a, b) => .sort((a, b) =>
sort === "name" sort === "name"
? a.name.localeCompare(b.name, "es") ? a.name.localeCompare(b.name, "es")
@@ -88,6 +132,77 @@ export function CatalogClient({
[age, allowedCategories, brand, category, collection, maxPrice, products, query, sort], [age, allowedCategories, brand, category, collection, maxPrice, products, query, sort],
); );
// Intercala un tile promocional cada PROMO_TILE_INTERVAL productos,
// ciclando por las categorias raiz -- si no hay jerarquia de
// categorias disponible, la grilla queda igual que antes (solo
// productos).
const gridItems = useMemo<GridItem[]>(() => {
if (promoRoots.length === 0) return filtered.map((product) => ({ type: "product", product }));
const items: GridItem[] = [];
let promoIndex = 0;
filtered.forEach((product, index) => {
items.push({ type: "product", product });
const isLast = index === filtered.length - 1;
if (!isLast && (index + 1) % PROMO_TILE_INTERVAL === 0) {
items.push({ type: "promo", category: promoRoots[promoIndex % promoRoots.length] });
promoIndex += 1;
}
});
return items;
}, [filtered, promoRoots]);
// Conteos por valor de filtro (patron Amazon: "Marca (12)"), calculados
// sobre los productos que ya pasan el resto de filtros activos -- cada
// dimension se cuenta excluyendose a si misma para reflejar cuantos
// resultados habria si se eligiera ese valor.
const categoryCounts = useMemo(() => {
const base = products.filter(
(product) => matchesQuery(product, query) && matchesCollection(product, collection) && matchesBrand(product, brand) && matchesAge(product, age) && matchesPrice(product, maxPrice),
);
const counts: Record<string, number> = { Todos: base.length };
for (const name of categories) {
if (name === "Todos") continue;
const allowed = categoryGroups[name] ?? [name];
counts[name] = base.filter((product) => matchesCategory(product, allowed)).length;
}
return counts;
}, [age, brand, categories, categoryGroups, collection, maxPrice, products, query]);
const brandCounts = useMemo(() => {
const base = products.filter(
(product) =>
matchesQuery(product, query) &&
(category === "Todos" || matchesCategory(product, allowedCategories)) &&
matchesCollection(product, collection) &&
matchesAge(product, age) &&
matchesPrice(product, maxPrice),
);
const counts: Record<string, number> = { Todas: base.length };
for (const value of brands) {
if (value === "Todas") continue;
counts[value] = base.filter((product) => product.brand === value).length;
}
return counts;
}, [age, allowedCategories, brands, category, collection, maxPrice, products, query]);
const ageCounts = useMemo(() => {
const base = products.filter(
(product) =>
matchesQuery(product, query) &&
(category === "Todos" || matchesCategory(product, allowedCategories)) &&
matchesCollection(product, collection) &&
matchesBrand(product, brand) &&
matchesPrice(product, maxPrice),
);
const counts: Record<string, number> = { Todas: base.length };
for (const value of ages) {
if (value === "Todas") continue;
counts[value] = base.filter((product) => product.ageRange === value).length;
}
return counts;
}, [ages, allowedCategories, brand, category, collection, maxPrice, products, query]);
const reset = () => { const reset = () => {
setQuery(""); setQuery("");
setCategory("Todos"); setCategory("Todos");
@@ -101,6 +216,27 @@ export function CatalogClient({
return ( return (
<div className="mx-auto max-w-7xl px-4 py-10"> <div className="mx-auto max-w-7xl px-4 py-10">
<div className="mb-8"> <div className="mb-8">
{breadcrumb.length > 0 && (
<nav aria-label="Breadcrumb" className="mb-4 flex flex-wrap items-center gap-1.5 text-xs font-bold text-slate-500">
<Link href="/catalog" prefetch={false} className="hover:text-fuchsia-600">
Inicio
</Link>
{breadcrumb.map((node, index) => (
<span key={node.id} className="flex items-center gap-1.5">
<ChevronRight className="size-3" />
{index === breadcrumb.length - 1 ? (
<span aria-current="page" className="text-slate-900">
{node.name}
</span>
) : (
<Link href={`/catalog?category=${encodeURIComponent(node.name)}`} prefetch={false} className="hover:text-fuchsia-600">
{node.name}
</Link>
)}
</span>
))}
</nav>
)}
<span className="text-xs font-black uppercase tracking-[.18em] text-fuchsia-600"> <span className="text-xs font-black uppercase tracking-[.18em] text-fuchsia-600">
Catálogo completo Catálogo completo
</span> </span>
@@ -134,9 +270,10 @@ export function CatalogClient({
values={categories} values={categories}
selected={category} selected={category}
onChange={setCategory} onChange={setCategory}
counts={categoryCounts}
/> />
<Filter title="Marca" values={brands} selected={brand} onChange={setBrand} /> <Filter title="Marca" values={brands} selected={brand} onChange={setBrand} counts={brandCounts} />
<Filter title="Edad" values={ages} selected={age} onChange={setAge} /> <Filter title="Edad" values={ages} selected={age} onChange={setAge} counts={ageCounts} />
<fieldset> <fieldset>
<legend className="mb-3 text-sm font-black">Precio máximo</legend> <legend className="mb-3 text-sm font-black">Precio máximo</legend>
@@ -180,9 +317,13 @@ export function CatalogClient({
{filtered.length ? ( {filtered.length ? (
<div className="grid gap-5 sm:grid-cols-2 xl:grid-cols-3"> <div className="grid gap-5 sm:grid-cols-2 xl:grid-cols-3">
{filtered.map((product) => ( {gridItems.map((item, index) =>
<ProductCard key={product.id} product={product} /> item.type === "product" ? (
))} <ProductCard key={item.product.id} product={item.product} />
) : (
<PromoTile key={`promo-${index}`} category={item.category} className="min-h-[22rem]" />
),
)}
</div> </div>
) : ( ) : (
<div className="grid min-h-80 place-items-center rounded-3xl border border-dashed border-slate-300 text-center"> <div className="grid min-h-80 place-items-center rounded-3xl border border-dashed border-slate-300 text-center">
@@ -205,11 +346,13 @@ function Filter({
values, values,
selected, selected,
onChange, onChange,
counts,
}: { }: {
title: string; title: string;
values: string[]; values: string[];
selected: string; selected: string;
onChange: (value: string) => void; onChange: (value: string) => void;
counts?: Record<string, number>;
}) { }) {
return ( return (
<fieldset> <fieldset>
@@ -227,6 +370,7 @@ function Filter({
}`} }`}
> >
{value} {value}
{counts && <span className="ml-1 opacity-60">({counts[value] ?? 0})</span>}
</button> </button>
))} ))}
</div> </div>
@@ -2,6 +2,7 @@ import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
import { ArrowUpRight } from "lucide-react"; import { ArrowUpRight } from "lucide-react";
import type { Category } from "@/lib/headless/types"; import type { Category } from "@/lib/headless/types";
import { cn } from "@/lib/utils";
type TileContent = { subtitle: string; image?: string; color: string }; type TileContent = { subtitle: string; image?: string; color: string };
@@ -20,6 +21,37 @@ const tileContent: Record<string, TileContent> = {
const defaultTile: TileContent = { subtitle: "Explora esta categoría", color: "from-slate-400 to-slate-600" }; const defaultTile: TileContent = { subtitle: "Explora esta categoría", color: "from-slate-400 to-slate-600" };
// Tile individual reutilizado tanto por la seccion de mundos del home
// como por el grid del catalogo (tiles promocionales intercalados,
// ADR 0005 seccion 3, patron Walmart) -- mismo primitivo visual, no un
// componente nuevo.
export function PromoTile({ category, className = "" }: { category: Category; className?: string }) {
const content = tileContent[category.handle] ?? defaultTile;
return (
<Link
href={`/catalog?category=${encodeURIComponent(category.name)}`}
className={cn(`group relative min-h-64 overflow-hidden rounded-[2rem] bg-gradient-to-br ${content.color} shadow-xl`, className)}
>
{content.image && (
<>
<Image src={content.image} alt={category.name} fill sizes="(max-width: 640px) 100vw, (max-width: 1024px) 33vw, 16vw" className="object-cover transition duration-500 group-hover:scale-105" />
<div className="absolute inset-0 bg-gradient-to-t from-slate-950/80 via-transparent to-white/5" />
</>
)}
<div className="absolute inset-x-0 bottom-0 flex items-end justify-between p-6 text-white">
<div>
<h3 className="text-xl font-black">{category.name}</h3>
<p className="mt-1 text-sm font-semibold text-white/80">{content.subtitle}</p>
</div>
<span className="grid size-11 shrink-0 place-items-center rounded-full bg-white text-slate-950 transition group-hover:rotate-45">
<ArrowUpRight />
</span>
</div>
</Link>
);
}
export function CategoryTiles({ categories }: { categories: Category[] }) { export function CategoryTiles({ categories }: { categories: Category[] }) {
const roots = categories.filter((category) => !category.parentId); const roots = categories.filter((category) => !category.parentId);
@@ -35,33 +67,9 @@ export function CategoryTiles({ categories }: { categories: Category[] }) {
<Link href="/catalog" className="hidden font-black text-cyan-700 sm:block">Ver todo →</Link> <Link href="/catalog" className="hidden font-black text-cyan-700 sm:block">Ver todo →</Link>
</div> </div>
<div className="grid gap-5 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6"> <div className="grid gap-5 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6">
{roots.map((category) => { {roots.map((category) => (
const content = tileContent[category.handle] ?? defaultTile; <PromoTile key={category.id} category={category} />
))}
return (
<Link
key={category.id}
href={`/catalog?category=${encodeURIComponent(category.name)}`}
className={`group relative min-h-64 overflow-hidden rounded-[2rem] bg-gradient-to-br ${content.color} shadow-xl`}
>
{content.image && (
<>
<Image src={content.image} alt={category.name} fill sizes="(max-width: 640px) 100vw, (max-width: 1024px) 33vw, 16vw" className="object-cover transition duration-500 group-hover:scale-105" />
<div className="absolute inset-0 bg-gradient-to-t from-slate-950/80 via-transparent to-white/5" />
</>
)}
<div className="absolute inset-x-0 bottom-0 flex items-end justify-between p-6 text-white">
<div>
<h3 className="text-xl font-black">{category.name}</h3>
<p className="mt-1 text-sm font-semibold text-white/80">{content.subtitle}</p>
</div>
<span className="grid size-11 shrink-0 place-items-center rounded-full bg-white text-slate-950 transition group-hover:rotate-45">
<ArrowUpRight />
</span>
</div>
</Link>
);
})}
</div> </div>
</section> </section>
); );
@@ -3,6 +3,7 @@
import Image from "next/image"; import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
import { Heart, ShoppingBag, Sparkles } from "lucide-react"; import { Heart, ShoppingBag, Sparkles } from "lucide-react";
import { useState } from "react";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import type { Product } from "@/lib/headless/types"; import type { Product } from "@/lib/headless/types";
@@ -16,19 +17,52 @@ export function ProductCard({ product, priority = false }: { product: Product; p
const wishlistHydrated = useWishlistStore((state) => state.hasHydrated); const wishlistHydrated = useWishlistStore((state) => state.hasHydrated);
const toggleProduct = useWishlistStore((state) => state.toggleProduct); const toggleProduct = useWishlistStore((state) => state.toggleProduct);
const isFavorite = wishlistHydrated && wishlistProducts.some((item) => item.id === product.id); const isFavorite = wishlistHydrated && wishlistProducts.some((item) => item.id === product.id);
const discountPercent =
product.compareAtPrice && product.price
? Math.round((1 - product.price / product.compareAtPrice) * 100)
: null;
const [selectedVariantId, setSelectedVariantId] = useState(product.variants[0]?.id);
return ( return (
<article className="group flex h-full flex-col overflow-hidden rounded-3xl border border-slate-100 bg-white shadow-lg shadow-slate-900/5 transition duration-300 hover:-translate-y-1.5 hover:shadow-2xl hover:shadow-violet-500/10"> <article className="group flex h-full flex-col overflow-hidden rounded-3xl border border-slate-100 bg-white shadow-lg shadow-slate-900/5 transition duration-300 hover:-translate-y-1.5 hover:shadow-2xl hover:shadow-violet-500/10">
<div className="relative aspect-square overflow-hidden bg-slate-50"> <div className="relative aspect-square overflow-hidden bg-slate-50">
<Link href={`/product/${product.slug}`} prefetch={false}><Image src={product.thumbnail} alt={product.name} fill priority={priority} sizes="(max-width: 640px) 82vw, (max-width: 1024px) 44vw, 280px" className="object-cover transition duration-500 group-hover:scale-[1.035]" /></Link> <Link href={`/product/${product.slug}`} prefetch={false}><Image src={product.thumbnail} alt={product.name} fill priority={priority} sizes="(max-width: 640px) 82vw, (max-width: 1024px) 44vw, 280px" className="object-cover transition duration-500 group-hover:scale-[1.035]" /></Link>
<div className="absolute left-3 top-3 flex gap-2">{product.isNew && <Badge className="bg-fuchsia-500 text-white">Nuevo</Badge>}{product.featured && <Badge className="bg-yellow-300 text-slate-950"><Sparkles className="mr-1 size-3" />Top</Badge>}</div> <div className="absolute left-3 top-3 flex gap-2">{discountPercent && discountPercent > 0 && <Badge className="bg-rose-600 text-white">-{discountPercent}%</Badge>}{product.isNew && <Badge className="bg-fuchsia-500 text-white">Nuevo</Badge>}{product.featured && <Badge className="bg-yellow-300 text-slate-950"><Sparkles className="mr-1 size-3" />Top</Badge>}</div>
<button type="button" aria-label={isFavorite ? "Quitar de favoritos" : "Agregar a favoritos"} aria-pressed={isFavorite} className={`absolute right-3 top-3 rounded-full p-2.5 shadow-lg backdrop-blur transition ${isFavorite ? "bg-fuchsia-500 text-white" : "bg-white/95 text-slate-900 hover:text-fuchsia-500"}`} onClick={() => toggleProduct(product)}><Heart className={`size-4 ${isFavorite ? "fill-current" : ""}`} /></button> <button type="button" aria-label={isFavorite ? "Quitar de favoritos" : "Agregar a favoritos"} aria-pressed={isFavorite} className={`absolute right-3 top-3 rounded-full p-2.5 shadow-lg backdrop-blur transition ${isFavorite ? "bg-fuchsia-500 text-white" : "bg-white/95 text-slate-900 hover:text-fuchsia-500"}`} onClick={() => toggleProduct(product)}><Heart className={`size-4 ${isFavorite ? "fill-current" : ""}`} /></button>
</div> </div>
<div className="flex flex-1 flex-col space-y-3 p-5"> <div className="flex flex-1 flex-col space-y-3 p-5">
<div className="flex items-center justify-between gap-2 text-xs font-bold text-slate-500"><span>{product.category}</span><span className="rounded-full bg-cyan-50 px-2 py-1 text-cyan-700">{product.collection}</span></div> <div className="flex items-center justify-between gap-2 text-xs font-bold text-slate-500"><span>{product.category}</span><span className="rounded-full bg-cyan-50 px-2 py-1 text-cyan-700">{product.collection}</span></div>
<Link href={`/product/${product.slug}`} prefetch={false}><h3 className="line-clamp-2 min-h-12 text-lg font-black leading-6 text-slate-950 group-hover:text-fuchsia-600">{product.name}</h3></Link> <Link href={`/product/${product.slug}`} prefetch={false}><h3 className="line-clamp-2 min-h-12 text-lg font-black leading-6 text-slate-950 group-hover:text-fuchsia-600">{product.name}</h3></Link>
<p className="line-clamp-2 min-h-10 text-sm leading-5 text-slate-500">{product.shortDescription}</p> <p className="line-clamp-2 min-h-10 text-sm leading-5 text-slate-500">{product.shortDescription}</p>
<div className="mt-auto flex items-center justify-between gap-3 pt-1"><strong className="text-sm font-black">{formatMoney(product.price, product.currency)}</strong><Button variant="magenta" size="sm" onClick={() => addItem(product, product.variants[0]?.id)}><ShoppingBag className="size-4" />Agregar</Button></div> {product.variants.length > 1 && (
<div className="flex flex-wrap gap-1.5">
{product.variants.map((variant) => (
<button
key={variant.id}
type="button"
disabled={!variant.available}
aria-pressed={selectedVariantId === variant.id}
aria-label={`${variant.name}: ${variant.value}`}
onClick={() => setSelectedVariantId(variant.id)}
className={`rounded-full border px-2.5 py-1 text-xs font-bold transition ${
selectedVariantId === variant.id
? "border-fuchsia-500 bg-fuchsia-50 text-fuchsia-700"
: "border-slate-200 text-slate-600 hover:border-slate-400"
} ${!variant.available ? "cursor-not-allowed opacity-40" : ""}`}
>
{variant.value}
</button>
))}
</div>
)}
<div className="mt-auto flex items-center justify-between gap-3 pt-1">
<div className="flex flex-col">
{product.compareAtPrice && <span className="text-xs font-bold text-slate-400 line-through">{formatMoney(product.compareAtPrice, product.currency)}</span>}
<strong className="text-sm font-black">{formatMoney(product.price, product.currency)}</strong>
</div>
<Button variant="magenta" size="sm" onClick={() => addItem(product, selectedVariantId)}><ShoppingBag className="size-4" />Agregar</Button>
</div>
</div> </div>
</article> </article>
); );
@@ -25,7 +25,7 @@ spec:
runAsUser: 1001 runAsUser: 1001
containers: containers:
- name: app - name: app
image: gitea.cruzcloud.net/devops/ecommerce-frontend:v1.0.143 image: gitea.cruzcloud.net/devops/ecommerce-frontend:v1.0.147
env: env:
- name: HEADLESS_PROVIDER - name: HEADLESS_PROVIDER
value: medusa value: medusa