import React, { useState } from 'react' import Button from '../../atoms/Button' import Icon from '../../atoms/Icon' import Price, { type PriceFormatter } from '../../atoms/Price' import { useQuickOrderDrawer } from './provider/QuickOrderDrawerProvider' export type QuickOrderDrawerFooterProps = { formatter?: PriceFormatter /** * Text labels for CMS configuration */ labels?: { itemsLabel?: string addToCartLabel?: string addToCartAriaLabel?: string } } const QuickOrderDrawerFooter = ({ formatter, labels, }: QuickOrderDrawerFooterProps) => { const [loading, setLoading] = useState(false) const { itemsCount, totalPrice, onAddToCart, formatter: contextFormatter, } = useQuickOrderDrawer() const priceFormatter = formatter || contextFormatter const { itemsLabel, addToCartLabel, addToCartAriaLabel } = labels || {} const handleAddToCart = async () => { if (itemsCount === 0) return setLoading(true) try { onAddToCart() } finally { setLoading(false) } } return (
{itemsCount} {itemsLabel || ''}
) } export default QuickOrderDrawerFooter