import PropTypes from 'prop-types' import React, { useEffect, useState } from 'react' import { PColor } from '../../../assets/colors' import { IconSales } from '../../../assets/icons' import { numberFormat } from '../../../utils/index' import { Column } from '../../atoms/Column' import { CustomLink } from '../../atoms/Link' import { Overline } from '../../atoms/Overline' import { AwesomeModal } from '../AwesomeModal' import { CardProductSimple } from '../CardProductSimple' import { ResisesColumns } from '../ResisesColumns' import { Text } from './../../atoms' import { Button } from './../../atoms/Button/index' import { Skeleton } from './../../molecules/Skeleton' import { ActionButton, ContainerGrid, HeaderWrapperDetail, ModalWrapper, SectionDetailOrder } from './styled' const CLIENT_URL_BASE = process.env.URL_BASE export const MemoModalDetailOrder = ({ dataModal = {}, dataStore, pDatCre, saleError, saleKey, saleGroup, openAction = false, isClient = false, edit = true, totalProductsPrice = 0, loading = false, handleOpenActions = () => { return }, handleModalItem = () => { return }, setModalItem = () => { return }, HandleChangeState = () => { return }, onPress = () => { return }, onClose = () => { return } }) => { const { payMethodPState, pSState, locationUser, pCodeRef, channel, change, getAllPedidoStore } = dataModal const dataLocation = (locationUser && JSON.parse(locationUser)) || {} const { cName, country, dName, uLocationKnow } = dataLocation const stateOrder = { 1: 'Confirmado', 2: 'En Proceso', 3: 'Listo Para Entrega', 4: 'Pedido Concluido', 5: 'Rechazado' } const { yearMonthDay, hourMinutes12, longDayName } = pDatCre || {} const [stateSale, setStateSale] = useState(pSState) useEffect(() => { // setStateSale() const data = dataModal?.hasOwnProperty('pSState') if (data) { setStateSale(pSState) } }, [dataModal]) const [openCommentModal, setOpenCommentModal] = useState(false) const [oneProductToComment, setOneProductToComment] = useState({}) const [values, setValues] = useState({}) const handleChange = (e, error) => { setValues({ ...values, [e.target.name]: e.target.value }) } const handleComment = (product, comment) => { if (product) { setOneProductToComment(product) setValues({ ...values, comment: comment || '' }) } setOpenCommentModal(!openCommentModal) } /** * Description * @param {any} value * @param {any} pCodeRef * @returns {any} **/ const handleChangeStateSale = (value, pCodeRef) => { if (stateSale !== value) { HandleChangeState(value, pCodeRef) setStateSale(value) } } const options = [ { value: 1, label: 'Confirmar pedido' }, { value: 2, label: 'Pedido en proceso' }, { value: 3, label: 'Pedido en listo para entrega' }, { value: 4, label: 'Pedido concluido' }, { value: 5, label: 'Rechazar pedido' } ] if (saleError) return <>Error return ( <> {openCommentModal && ( { return handleComment() }} onHide={() => { return handleComment() }} padding='20px' show={openCommentModal} size='400px' title='Mira los comentarios' zIndex='9999' >