import { getGlobalStyle } from "../../../../helpers"; import { Column, Icon } from "../../../atoms"; import { EmptyData } from "../../../molecules"; import { SwipeableCard } from "../../../molecules/SwipeableCard"; import { MiniCardProduct } from "../../../organisms"; interface ProductsSalesProps { isLoading: boolean; data: any; dispatch: React.Dispatch; onClick: (product: any) => void; handleAddProduct: (product: any) => void; handleComment: (product: any) => void; handleDecrement: (product: any) => void; handleFreeProducts: (product: any) => void; numberFormat: (value: string | number) => string | number; } export const ProductsSales: React.FC = ({ isLoading, data, dispatch, onClick, handleComment, handleDecrement, handleFreeProducts, handleAddProduct, numberFormat }) => { return <> {!isLoading && data.PRODUCT.length > 0 ? ( data.PRODUCT.map((product: any, index: number) => { const tag = { tag: product?.getOneTags?.nameTag ?? '' } const ProQuantity = product?.ProQuantity ?? 0 const ProPrice = product.ProPrice return ( { dispatch({ type: 'REMOVE_PRODUCT_TO_CART', payload: product }) }} onSwipeUp={() => { onClick(product) }} rightActions={ {/* sub productos */} } > { dispatch({ type: 'REMOVE_PRODUCT_TO_CART', payload: product }) }} handleChangeQuantity={(event) => { const { value } = event.target return dispatch({ type: 'ON_CHANGE', payload: { id: product.pId, index, value } }) }} ProDescription={product.ProDescription} plainPrice={ProPrice} ProDescuento={product.ProDescuento} ProImage={product.ProImage} ProPrice={numberFormat(ProPrice)} discount={numberFormat(product.ProDescuento) ?? 0} ProQuantity={ProQuantity} handleToggleEditingStatus={() => { dispatch({ type: 'TOGGLE_EDITING_PRODUCT', payload: product }) }} handleCancelUpdateQuantity={() => { dispatch({ type: 'CANCEL_UPDATE_QUANTITY_EDITING_PRODUCT', payload: product }) }} handleSuccessUpdateQuantity={() => { dispatch({ type: 'UPDATE_SUCCESS_QUANTITY_EDITING_PRODUCT', payload: product }) }} ValueDelivery={product.ValueDelivery} withQuantity={true} hoverFree={true} free={ProPrice === 0} handleComment={() => { handleComment(product) }} showDot={true} hasDiscount={true} openQuantity={Boolean(ProQuantity)} handleDecrement={() => { handleDecrement(product) }} handleIncrement={() => { handleAddProduct(product) }} handleFreeProducts={() => { handleFreeProducts(product) }} handleGetSubItems={() => { onClick(product) }} edit={false} onClick={() => { handleAddProduct(product) }} pName={product.pName} render={} tag={product?.getOneTags?.nameTag !== null && tag} /> ) }) ) : ( ) } ; }