import React from 'react' import PropTypes from 'prop-types' import styled, { keyframes } from 'styled-components' import { IconInformationProduct, IconMiniCheck } from '../../../assets' import { getGlobalStyle } from '../../../utils' import { Button, Icon, Row, Text } from '../../atoms' import { calculateRemainingTime, color } from './helpers' import style from './CardOrder.module.css' interface CardOrderProps { pCodeRef?: string view?: boolean pDatCre?: string deliveryTimeMinutes?: number | null handleViewOrder?: (pCodeRef: string) => string } export const CardOrder: React.FC = ({ pCodeRef = '', view = true, pDatCre = '', deliveryTimeMinutes = null, handleViewOrder = (pCodeRef: string) => pCodeRef }) => { const label = 'Nuevo Pedido' const { minutes, hour, remainingTimeText, entregaText, delay } = deliveryTimeMinutes !== null ? calculateRemainingTime(pDatCre, deliveryTimeMinutes) : { minutes: '', hour: '', remainingTimeText: '', entregaText: '', delay: false } return (
{label}
# {pCodeRef}
Confirmar pedido
{Boolean(delay) && ( {`Retrasado: ${remainingTimeText}`} )} {Boolean(!(delay ?? false)) &&
{Boolean(!(delay ?? false)) && ( {`Tiempo de entrega: ${hour !== null ? hour : ''} ${ minutes ?? '' }`} )}
} {Boolean(!(delay ?? false)) &&
{Boolean(!(delay ?? false)) && ( {entregaText} )}
}
) } CardOrder.propTypes = { pCodeRef: PropTypes.string, pDatCre: PropTypes.string, deliveryTimeMinutes: PropTypes.oneOfType([ PropTypes.number, PropTypes.oneOf([null]) ]), view: PropTypes.bool, handleViewOrder: PropTypes.func } const pulse = keyframes` 0% { transform: scale(1); opacity: .75; } 25% { transform: scale(1); opacity: .75; } 100% { transform: scale(2.5); opacity: 0; } ` interface BubbleProps { color?: string } export const Bubble = styled.div` display: block; position: relative; margin: 0; &:hover:after { background-color: ${({ color }) => color ?? ''}; } &:after { content: ""; background-color: ${({ color }) => color ?? ''}; width: 12px; height: 12px; border-radius: 50%; position: absolute; display: block; top: 1px; left: 1px; } .bubble-outer-dot { margin: 1px; display: block; text-align: center; opacity: 1; background-color: ${({ color }) => color ?? ''}; width: 12px; height: 12px; border-radius: 50%; animation: ${pulse} 1.5s linear infinite; } .bubble-inner-dot { display: block; text-align: center; opacity: 1; background-color: ${({ color }) => color ?? ''}; width: 12px; height: 12px; border-radius: 50%; animation: ${pulse} 1.5s linear infinite; } .bubble-inner-dot:after { content: ""; display: block; text-align: center; opacity: 1; background-color: ${({ color }) => color ?? ''}; width: 12px; height: 12px; border-radius: 50%; animation: ${pulse} 1.5s linear infinite; } ` Bubble.displayName = 'Bubble'