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" function getOrderForm(cards: Array) { if(cards.length > 0) { const options = cards.map(card => ); 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 { return (
Su carrito está vacío, añada algunos productos para empezar a comprar.
); } } 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}
{order_form}
); }