From e8fa9bd7bba125a339f11876eb5ea99d0cd301b6 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 25 May 2023 19:11:31 -0600 Subject: Añade historial de órdenes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/account/cart.tsx | 72 +++++++++++++++++++++++++++++++++++++------ src/routes/account/orders.tsx | 14 +++++++++ 2 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 src/routes/account/orders.tsx (limited to 'src/routes') diff --git a/src/routes/account/cart.tsx b/src/routes/account/cart.tsx index a98cf20..cc81756 100644 --- a/src/routes/account/cart.tsx +++ b/src/routes/account/cart.tsx @@ -1,25 +1,60 @@ -import { useLoaderData } from "react-router-dom"; -import { cartLoader } from "../../clients/loaders"; +import { Form, useLoaderData } from "react-router-dom"; import ProductCart from "../../components/product_cart"; import { Product } from "../../models/product"; import MainContentLayout from "../../components/main_content_layout"; import { CartXFill } from "react-bootstrap-icons"; +import { Card } from "../../models/card"; +import "../../components/stylesheets/shared.css" -export default function Cart() { - let products; - const data = useLoaderData() as Array; +function getOrderForm(cards: Array) { + if(cards.length > 0) { + const options = cards.map(card => + + ); - if(data.length > 0) { - products = data.map(product => + return( +
+
+

+ Completar pago +

+
+
+
+ +
+
+ +
+
+
+ ); + } + else { +
+ + No tiene ningún método de pago configurado. + +
+ } +} + +function getProducts(product_data: Array) { + if(product_data.length > 0) { + return (product_data.map(product =>
- ); + )); } else { - products = ( + return (
@@ -30,11 +65,28 @@ export default function Cart() {
); } +} + +export default function Cart() { + const product_data = useLoaderData()[0] as Array; + const cards_data = useLoaderData()[1] as Array; + let order_form; + const products = getProducts(product_data); + + if(product_data.length > 0) + order_form = getOrderForm(cards_data); + else + order_form = null; return( <> - {products} +
+
+ {products} +
+ {order_form} +
); diff --git a/src/routes/account/orders.tsx b/src/routes/account/orders.tsx new file mode 100644 index 0000000..1e655d1 --- /dev/null +++ b/src/routes/account/orders.tsx @@ -0,0 +1,14 @@ +import { useLoaderData } from "react-router-dom"; +import MainContentLayout from "../../components/main_content_layout"; +import OrderTable from "../../components/order_table"; + + +export default function Orders() { + const orders = useLoaderData(); + + return( + + + + ); +} \ No newline at end of file -- cgit v1.2.3