diff --git a/src/pages/catalog/Catalog.module.css b/src/pages/catalog/Catalog.module.css index 5627c44..4cc0c84 100644 --- a/src/pages/catalog/Catalog.module.css +++ b/src/pages/catalog/Catalog.module.css @@ -23,14 +23,17 @@ top: 2rem; /* se queda pegada al hacer scroll */ height: fit-content; /* sólo el alto que necesite su contenido */ background: rgba(255, 255, 255, 0.9); - border: 1px solid darkviolet; + border: 1px solid snow; border-radius: 24px; box-shadow: 0 48px 56px rgba(0, 0, 0, 0.1); padding: 1.5rem; + transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease; + cursor: pointer; } .order:hover { - border: 3px dotted darkviolet; + transform: translateY(-8px) scale(1.02); + box-shadow: 0 36px 64px rgba(0, 0, 0, 0.15); } /* Responsive: en pantallas estrechas se apilan */ diff --git a/src/pages/catalog/Catalog.tsx b/src/pages/catalog/Catalog.tsx index 6529efb..9efdd61 100644 --- a/src/pages/catalog/Catalog.tsx +++ b/src/pages/catalog/Catalog.tsx @@ -1,12 +1,13 @@ import { ProductCards } from "./components"; import { useEffect, useState } from "react"; -import type { Product } from "../../types"; +import type { Product, ProductLine } from "../../types"; import Order from "./components/order/Order"; import styles from "./Catalog.module.css"; const Catalog = () => { const [products, setProducts] = useState([]); + const [productLines, setProductLines] = useState([]); useEffect(() => { async function fetchProducts(){ @@ -21,14 +22,25 @@ const Catalog = () => { fetchProducts(); }, []); + function addProductLine(product: Product, quantity: number){ + const newProductLine: ProductLine = { + id: Date.now(), + product: product, + quantity: quantity, + unitPrice: product.price, + totalAmount: quantity * product.price, + }; + + setProductLines([...productLines, newProductLine]); + } return (
- +
) diff --git a/src/pages/catalog/components/order/Order.tsx b/src/pages/catalog/components/order/Order.tsx index acc6b6c..00cb5e7 100644 --- a/src/pages/catalog/components/order/Order.tsx +++ b/src/pages/catalog/components/order/Order.tsx @@ -1,6 +1,13 @@ +import OrderLine from './components/order_line/OrderLine'; import styles from './Order.module.css' +import type { ProductLine } from '../../../../types.ts' + +type OrderProps = { + productLines: ProductLine[]; +} + +const Order = ({productLines = []} : OrderProps) => { -const Order = () => { return (

Compra #5428

@@ -11,16 +18,16 @@ const Order = () => {
-

Tomate Orgánico 500g 12000

-

Espinaca Orgánica 250g 8500

-

Zanahoria Orgánica 1Kg 9500

-

Palta Orgánica 1U 4500

-

Banano Orgánico 1Kg 5500

-

Mango Orgánico 1U 3500

-

Fresa Orgánica 250g 12000

-

Pimentón Orgánico 500g 10500

-

Cebolla Orgánica 500g 5500

-

Manzana Orgánica 500g 8000

+ { productLines.length > 0 ? ( + + productLines.map((line) => { + return + } + + )) : ( +

No hay productos en el pedido

+ ) + }
@@ -28,10 +35,15 @@ const Order = () => { Domicilio: $10.000 COP
Total: $210.000 COP
+
+ + +
- -
- +
+ + +
) } diff --git a/src/pages/catalog/components/order/components/order_line/OrderLine.tsx b/src/pages/catalog/components/order/components/order_line/OrderLine.tsx new file mode 100644 index 0000000..ee4bfea --- /dev/null +++ b/src/pages/catalog/components/order/components/order_line/OrderLine.tsx @@ -0,0 +1,20 @@ +import type { ProductLine } from '../../../../../../types.ts' + + +type OrderLineProps = { + line: ProductLine; +} + + +const OrderLine = ( {line} : OrderLineProps ) => { + const { product, quantity, unitPrice, totalAmount } = line; + + return ( + <> +

{product.name} {quantity}{product.uomSymbol} {unitPrice} {totalAmount}

+ + ) +} + + +export default OrderLine; diff --git a/src/pages/catalog/components/order/components/order_line/index.ts b/src/pages/catalog/components/order/components/order_line/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/catalog/components/product_cards/ProductCards.module.css b/src/pages/catalog/components/product_cards/ProductCards.module.css index b2b997b..50c4a43 100644 --- a/src/pages/catalog/components/product_cards/ProductCards.module.css +++ b/src/pages/catalog/components/product_cards/ProductCards.module.css @@ -2,7 +2,7 @@ .container { display: flex; justify-content: center; - border: 1px solid darkviolet; + border: 1px solid snow; display: flex; flex-wrap: wrap; border-radius: 32px; diff --git a/src/pages/catalog/components/product_cards/ProductCards.tsx b/src/pages/catalog/components/product_cards/ProductCards.tsx index 5b4cf81..c70e2d3 100644 --- a/src/pages/catalog/components/product_cards/ProductCards.tsx +++ b/src/pages/catalog/components/product_cards/ProductCards.tsx @@ -5,23 +5,15 @@ import styles from "./ProductCards.module.css" type ProductCardProps = { products: Product[]; + addProductLine: (product: Product, quantity: number) => void; } -const ProductCards = ({ products } : ProductCardProps) => { - +const ProductCards = ({ products, addProductLine } : ProductCardProps) => { return (
{ products.map((product) => { return ( -
- -
+ ) }) }
diff --git a/src/pages/catalog/components/product_cards/components/card/Card.module.css b/src/pages/catalog/components/product_cards/components/card/Card.module.css index 3e87e5f..353d376 100644 --- a/src/pages/catalog/components/product_cards/components/card/Card.module.css +++ b/src/pages/catalog/components/product_cards/components/card/Card.module.css @@ -6,26 +6,30 @@ border: 3px solid snow; box-shadow: 0 24px 56px rgba(0, 0, 0, 0.1); width: 325px; - height: 500px; + height: 530px; padding: 10px; margin: 8px; + transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease; + cursor: pointer; } .container:hover { - border: 3px dotted pink; + /* border: 3px dotted black; */ + transform: translateY(-8px) scale(1.02); + box-shadow: 0 36px 64px rgba(0, 0, 0, 0.15); } .button_container { display: flex; flex-direction: column; - gap: 16px + gap: 8px } .button_container button { display: flex; flex-direction: column; font-weight: bold; - background-color: #667eea; + background-color: #F54A27; color: white; border: none; border-radius: 8px; @@ -37,5 +41,45 @@ } .button_container button:hover { - background-color: #5a6fd8; + background-color: #FF907D; +} + + +.product_name { + font-size: 1.5rem; + font-weight: 600; + color: #F54A27; + margin: 4px 0 8px 0; + text-align: center; + letter-spacing: -0.5px; +} + +.price { + font-size: 1.8rem; + font-weight: 700; + color: #F54A27; /* Mismo color que tus botones para consistencia */ + margin: 8px 0 16px 0; + text-align: center; + background: linear-gradient(120deg, #F54A27 0%, #764ba2 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; +} + +.description { + font-size: 0.95rem; + /* color: #666; */ + text-align: center; + margin: 16px 0; + line-height: 1.4; + flex-grow: 1; /* Para que ocupe el espacio disponible */ +} + + +.details { + margin: 8px 0 16px; + text-align: center; + font-size: 1rem; + /* color: #666; */ + cursor: pointer; } diff --git a/src/pages/catalog/components/product_cards/components/card/card.tsx b/src/pages/catalog/components/product_cards/components/card/card.tsx index 30afe81..6ea722a 100644 --- a/src/pages/catalog/components/product_cards/components/card/card.tsx +++ b/src/pages/catalog/components/product_cards/components/card/card.tsx @@ -1,25 +1,36 @@ +import { useState } from 'react'; +import type { Product } from '../../../../../../types'; import styles from './Card.module.css' type CardProps = { - image: string; - name: string; - price: number; - description: string; - cardId: number + product: Product; + addProductLine: (product: Product, quantity: number) => void; } -const Card = ({ image, name, price, description, cardId } : CardProps) => { +const Card = ({ product, addProductLine } : CardProps) => { + const {id, name, price, description, image } = product; + const [quantity, setQuantity] = useState(0); + return ( -
- Imagen -

{name}

-

{price}

-

{description}

+
+

{name}

+ + {`${description}`}/ +

${price} COP

+ +
+ Ver descripción +

{description}

+
+ + setQuantity(Number(event.target.value)) + }/>
- +
) diff --git a/src/types.ts b/src/types.ts index 6693298..2ba807a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,4 +4,15 @@ export type Product = { price: number; description: string; image: string; + uomId: number; + uomSymbol: string; + unitPrice: number; }; + +export type ProductLine = { + id: number; + product: Product; + quantity: number; + unitPrice: number; + totalAmount: number; +}