import { useState } from 'react' import { __ } from '@wordpress/i18n' import classNames from 'classnames' import { wbkFormatPrice } from '../../../providers/BookingFormProvider/utils' import { useBookingContext } from '../../../providers/BookingFormProvider/BookingFormProvider' import { useBookingSummaryTotal } from '../../../hooks/useBookingSummaryTotal' import { getSelectedStaffLabel } from '../../../components/StaffSelector/utils' import { IStaffOption } from '../../../components/StaffSelector/types' import { ReactComponent as ArrowDownIcon } from '../../../../../public/images/arrow-down.svg' export const WaterfallSummary = () => { const { sortedItems, totalFormatted, displayTax, depositTotal, hasSummaryAmounts, hideAllPrices, amountData, priceFormat, wording, } = useBookingSummaryTotal() const { formData, preset } = useBookingContext() const [showDetails, setShowDetails] = useState(false) const staffMembers = preset?.staff_members as IStaffOption[] | undefined const formStaff = typeof formData?.staff === 'object' && formData.staff !== null ? (formData.staff as Record) : undefined const anyAvailableLabel = wording.any_available || __('Any available', 'webba-booking-lite') if (!sortedItems.length) { return null } return (

{wording.summary || __('Summary', 'webba-booking-lite')}

{!hideAllPrices && ( <>
{wording.total || __('Total', 'webba-booking-lite')} {totalFormatted}

{wording.tax_included || __('Tax incl.', 'webba-booking-lite')}

{hasSummaryAmounts && (
{showDetails && (
{wording.total_booked_items || __( 'Total booked items', 'webba-booking-lite' )} : {wbkFormatPrice( Number(amountData?.subtotal || 0), priceFormat )}
{Number(amountData?.service_fees) > 0 && (
{wording.service_fees || __( 'Service fees', 'webba-booking-lite' )} : {wbkFormatPrice( Number(amountData.service_fees), priceFormat )}
)} {displayTax > 0 && (
{wording.tax || __( 'Sales tax', 'webba-booking-lite' )} : {wbkFormatPrice( displayTax, priceFormat )}
)}
{wording.grand_total || __( 'Grand total', 'webba-booking-lite' )} : {wbkFormatPrice( Number(amountData?.total || 0), priceFormat )}
{depositTotal > 0 && (
{wording.deposits || __( 'Deposits', 'webba-booking-lite' )} : {wbkFormatPrice( depositTotal, priceFormat )}
)} {Number(amountData?.left_to_pay) > 0 && (
{wording.left_to_pay_later || __( 'Left to pay later', 'webba-booking-lite' )} : {wbkFormatPrice( Number(amountData.left_to_pay), priceFormat )}
)}
)}
)} )}
) }