From da2631822f902094e691143302d6fc6b68e1cf56 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Wed, 24 May 2023 20:18:00 -0600 Subject: Añade lógica de carrito MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/products/product.tsx | 51 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'src/routes/products/product.tsx') diff --git a/src/routes/products/product.tsx b/src/routes/products/product.tsx index 1eecbcf..cca4073 100644 --- a/src/routes/products/product.tsx +++ b/src/routes/products/product.tsx @@ -1,12 +1,18 @@ -import { useLoaderData } from "react-router-dom"; +import { useLoaderData, Form, useActionData } from "react-router-dom"; import { CartPlusFill } from "react-bootstrap-icons" +import { InfoModal } from "../../components/info_modal"; +import { Modal } from "flowbite"; import ProductListing from "../../components/product_listing"; import MainContentLayout from "../../components/main_content_layout"; import Review from "../../components/review"; import "../../components/stylesheets/shared.css" +import { useEffect } from "react"; + export default function Product() { + let quantity_field; const response = useLoaderData(); + const response_status = useActionData(); const product = response[0].data; const reviews = response[1].data.data.map(review =>
  • @@ -14,23 +20,60 @@ export default function Product() {
  • ); + useEffect(() => { + const target = document.getElementById("info-modal"); + const options = { + placement: 'center-center', + backdrop: 'dynamic', + backdropClasses: 'bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-40', + closable: true + }; + const modal = new Modal(target, options); + document.getElementById('modal-button')?.addEventListener("click", () => { + modal.hide(); + }); + + if(response_status == 200) + modal.show(); + + }, [response_status]); + + if(response_status == 422) { + quantity_field = ( +
    + +
    + ); + } + else { + quantity_field = ( +
    + +
    + ); + } + return ( <>
    -
    - -
    +
      {reviews}
    +
    ); -- cgit v1.2.3