import React, { useEffect, useRef, useState } from 'react';
import bookingCSS from '../templates/BookingFunnel/index.module.css';
import ArrowSVG from '../assets/icons/icon_angle.svg';
import LogoRawSVG from '../assets/icons/logo-raw.svg';
import Link from '../blocks/Link';
import CloseSVG from '../assets/icons/icon_close.svg';
import AddressMap from '../components/AddressMap';
import { Button } from '../index';
import { getAmountWithCurrency } from './priceHelper';
export const BookingHeader = ({ LinkProps, steps, title }): JSX.Element => {
const [isSticky, setSticky] = useState(false);
const headerRef = useRef(null);
const handleScroll = (): void => {
if (headerRef.current) {
setSticky(headerRef.current.getBoundingClientRect().top <= 0);
}
};
useEffect(() => {
window.addEventListener('scroll', handleScroll);
return (): void => {
window.removeEventListener('scroll', () => handleScroll);
};
}, []);
return (
<>
{
// Flexbox div for centering pagination
}
>
);
};
export const AddressModal = ({
closeAddressValidationModal,
translations,
addressModalProps,
position,
continueEvent,
googleApiKey,
}): JSX.Element => {
return (
<>
{translations.mapTitle}
{translations.mapText}
{addressModalProps.address?.street +
' ' +
addressModalProps.address?.streetNr +
' ' +
addressModalProps.address?.zip +
' ' +
addressModalProps.address?.city}
{position != null && (
)}
>
);
};
export const LoginModal = ({
LoginForm,
title,
closeLoginModal,
handlePasswordForgot,
}): JSX.Element => {
return (
{title}
{
closeLoginModal();
}}
handlePasswordForgot={handlePasswordForgot}
/>
);
};
export const RegisterModal = ({
RegisterForm,
title,
closeRegisterModal,
token,
successText,
closeText,
}): JSX.Element => {
const [isSuccessful, setIsSuccessful] = useState(false);
return (
{title}
{!isSuccessful ? (
{
setIsSuccessful(true);
}}
/>
) : (
<>
{successText}
>
)}
);
};
export const PasswordResetModal = ({
PasswordResetForm,
title,
closePasswordResetModal,
handleAlreadyRegistered,
}): JSX.Element => {
return (
{title}
{
closePasswordResetModal();
}}
handleAlreadyRegistered={handleAlreadyRegistered}
/>
);
};
export const SummaryContent = ({
translations,
isUk,
locale,
serviceDetailsData,
serviceBillingData,
draftServiceCall,
isMilaFriend,
}): JSX.Element => {
return (
<>
{translations.summary}
{!serviceDetailsData?.isFlexibleCheckbox && (
<>
{translations.dateTime}
{new Intl.DateTimeFormat(isUk ? 'en-UK' : locale, {
weekday: 'long',
month: 'long',
year: 'numeric',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
}).format(serviceDetailsData?.date)}
>
)}
{translations.serviceLocation}
{serviceBillingData.additional && (
{serviceBillingData.additional}
)}
{serviceBillingData?.street + ' ' + serviceBillingData?.streetNr}
{serviceBillingData?.zip + ' ' + serviceBillingData?.city}
{serviceBillingData?.country}
{draftServiceCall.servicePackages.map((sp, i) => {
return (
{sp.name}
{sp.price.toFixed(2)}
{draftServiceCall.currency}
{isMilaFriend ? <> *> : ''}
);
})}
{draftServiceCall.vouchers.map((voucher, i) => {
return (
{translations.voucher} ({voucher.code})
- {voucher.calculatedDiscountAmount.toFixed(2)}
{draftServiceCall.currency}
);
})}
{draftServiceCall.priceHappinessGuaranteeDiscounted ? (
{translations.priceHappiness}
{draftServiceCall.priceHappinessGuaranteeDiscounted.toFixed(
2,
)}
{draftServiceCall.currency}
) : (
<>>
)}
{translations.total}
{`${draftServiceCall.priceDiscounted.toFixed(2)} ${
draftServiceCall.currency
} ${isMilaFriend ? '*' : ''}`}
{isMilaFriend && translations.summaryInfo}
>
);
};
export const SummaryGiftCard = ({
translations,
serviceBillingData,
amount,
isPdf,
currencyCode,
}): JSX.Element => {
return (
<>
{translations.summary}
{translations.serviceLocation}
{serviceBillingData.additional && (
{serviceBillingData.additional}
)}
{serviceBillingData?.street + ' ' + serviceBillingData?.streetNr}
{serviceBillingData?.zip + ' ' + serviceBillingData?.city}
{serviceBillingData?.country}
Gift Card
{getAmountWithCurrency(amount, currencyCode)}
{!isPdf ? (
{translations.shipping.replace('+ ', '').split(':')[0]}
{getAmountWithCurrency(3, currencyCode)}
) : (
<>>
)}
{translations.total}
{getAmountWithCurrency(
isPdf ? amount : amount + 3,
currencyCode,
)}
>
);
};