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 =>
  • ); 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 ( <>
    {quantity_field}
      {reviews}
    ); }