import Image from 'next/image' import Link from 'next/link' import PropTypes from 'prop-types' import { BGColor, PColor, PLColor } from '../../../assets/colors' import { IconArrowBottom, IconMiniCheck } from '../../../assets/icons' import { numberFormat } from '../../../utils' import { Checkbox, Overline, RippleButton, Tag, Text } from '../../atoms' import { ChoicesHeader, InputHooks, QuantityButton } from '../../molecules' import { CardsComponent, ContainerModal, DisRestaurant, GarnishChoicesHeader } from './styled' import styles from './ModalProduct.module.css' /** * Represents a modal displaying product information and options. * @param {Object} props - The props object. * @param {Object} [props.dataOneProduct={ pId: null }] - The data for one product. * @param {Array} [props.dataOptional=[]] - Optional data for additional product options. * @param {boolean} [props.show=false] - Flag indicating whether the modal should be shown. * @param {string} [props.comments=''] - Comments related to the product. * @param {number} [props.quantity=1] - The quantity of the product. * @param {boolean} [props.disabled=true] - Flag indicating whether the product is disabled. * @param {boolean} [props.loading=false] - Flag indicating whether the product is in a loading state. * @param {Array} [props.dataExtra=[]] - Extra data related to the product. * @param {Function} [props.handleShowModalProduct=()=>{}] - Function to handle showing/hiding the modal. * @param {Function} [props.setComments=(comment)=>comment] - Function to set comments related to the product. * @param {Function} [props.handleDecrementExtra=()=>{}] - Function to handle decrementing extra product options. * @param {Function} [props.handleIncrementExtra=()=>{}] - Function to handle incrementing extra product options. * @param {Function} [props.handleDecrease=()=>{}] - Function to handle decreasing the quantity of the product. * @param {Function} [props.handleIncrease=()=>{}] - Function to handle increasing the quantity of the product. * @param {Function} [props.handleAddOptional=({ exOptional, codeCategory })=>({ exOptional, codeCategory })] - Function to handle adding optional product options. * @param {Function} [props.useEvents=(args)=>args] - Function to use events related to the product. * @param {Function} [props.handleAddProducts=()=>{}] - Function to handle adding products. * @param {Function} [props.handleCountProducts=({ ProPrice, quantity })=>({ ProPrice, quantity })] - Function to handle counting products. * @returns {JSX.Element} JSX element representing the modal. */ export const ModalProduct = ({ dataOneProduct = { pId: null }, dataOptional = [], show = false, loadingButton = false, comments = '', quantity = 1, disabled = true, loading = false, dataExtra = [], handleShowModalProduct = () => { }, setComments = (comment) => { return comment }, handleDecrementExtra = () => { }, handleIncrementExtra = () => { }, handleDecrease = () => { }, handleIncrease = () => { }, handleAddOptional = ({ exOptional, codeCategory }) => { return { exOptional, codeCategory } }, useEvents = (args) => { return args }, handleAddProducts = () => { }, handleCountProducts = ({ ProPrice, quantity }) => { return { ProPrice, quantity } } }) => { const { ProDescription, ProDescuento, ProPrice, getStore, pName } = dataOneProduct || { ProDescription: '', ProDescuento: 0, ProPrice: 0, getStore: {}, pName: '' } useEvents({ eventType: 'app.cart', callBack: ({ detail: { items } }) => { // handleMutate(items) } }) const storeUrl = `/delivery/${getStore?.city?.cName?.toLocaleLowerCase()}-${getStore?.department?.dName?.toLocaleLowerCase()}/${getStore?.storeName }/${getStore?.idStore}` return (
Picture
{pName}
Picture

{ProDescription}

{ProDescuento && $ {numberFormat(ProDescuento)} } {' '} {getStore?.storeName}
{ return setComments(e.target.value) }} as='textarea' value={comments} /> {!!dataExtra?.length && (

Adicionales

Escoge las opciones.

)} {dataExtra?.length > 0 && dataExtra?.map((extra, index) => { const contentPrice = extra.extraPrice === 0 && extra.quantity == 0 return (

{extra.extraName}

{' '} {!contentPrice ? `$ ${numberFormat( (extra?.newExtraPrice ?? extra.extraPrice) || 0 )}` : 'Gratis'}

{extra.exState === 1 && }
{ return handleDecrementExtra({ extra, index }) }} handleIncrement={() => { return handleIncrementExtra({ extra, index }) }} padding='5px' quantity={extra.quantity} showNegativeButton={extra.quantity === 0} style={{ display: 'flex', justifyContent: 'flex-end' }} validationZero={false} width='min-content' />
) })} {dataOptional?.map((itemOptional) => { return (
0 ? itemOptional?.numbersOptionalOnly : ''} /> {itemOptional?.ExtProductFoodsSubOptionalAll?.map((x) => { return (

{x.OptionalSubProName}

{ return handleAddOptional({ exOptional: x.opSubExPid, codeCategory: itemOptional?.code }) }} type='checkbox' value={x?.check} />
) })}
) })}
{ return handleAddProducts(dataOneProduct) }} loading={loadingButton} padding='5px' size='12px' > Agregar
) } ModalProduct.propTypes = { comments: PropTypes.string, dataExtra: PropTypes.array, dataOneProduct: PropTypes.object, dataOptional: PropTypes.array, disabled: PropTypes.bool, handleAddOptional: PropTypes.func, handleAddProducts: PropTypes.func, handleCountProducts: PropTypes.func, handleDecrease: PropTypes.func, handleDecrementExtra: PropTypes.func, handleIncrease: PropTypes.func, handleIncrementExtra: PropTypes.func, handleShowModalProduct: PropTypes.func, loading: PropTypes.bool, quantity: PropTypes.number, setComments: PropTypes.func, show: PropTypes.bool, useEvents: PropTypes.func }