/* eslint-disable */ import React, { FC, ReactType, ReactNode, useState, useRef } from 'react'; import classnames from 'classnames'; import Layout from '../../components/Layout'; import Button from '../../blocks/Button'; import Price from '../../blocks/Price'; import css from './index.module.css'; import Accordion from '../../blocks/Accordion'; import Banner, { BannerProps } from '../../components/Banner'; import SVGStarFilled from '../../assets/icons/icon-star-filled.svg'; import SVGStarStroked from '../../assets/icons/icon-star-stroked.svg'; import SVGStarStrokedHalf from '../../assets/icons/icon-star-stroked-half.svg'; import ClockSVG from '../../assets/icons/clock.svg'; import { useScrollPosition } from '@n8tb1t/use-scroll-position'; import Discount from '../../blocks/Discount'; import { getAmountWithCurrency, getReduction } from '../../helpers/priceHelper'; import Ribbon from '../../components/Ribbon'; import SaleSVG from '../../assets/icons/ribbon-sale.svg'; export interface PackagePageProps { id: number; name: string; title: string; titleDescription: string; description: string; descriptionMore?: string; Image?: ReactType; ImageProps: unknown; price: number; originalPrice?: number; priceLabelMessage: string; currencyIsoCode: string; Link: ReactType; ButtonToCheckout: ReactType; BannerProps?: BannerProps; duration?: string; durationType?: string; durationTypeText?: string; durationLabel?: string; faq?: ReactType; averageRating: number; rating?: number; ratings?: { count: number; items: { id: number; firstName: string; rating: number; feedback: string; createdAt: string; }[]; }; faqs?: { id: number; question: string; answer: string; }[]; reviews?: ReactType; selectedOption?: string; partnerType?: string; partnerMessage: string; partnerMessageDescription: string; showMoreRatingsLabel: string; handleRatingShowMoreClick?: () => void; isLoadingRatings?: boolean; ratingsLabel: string; notes?: string; notesTitle: string; campaign?: string; } export interface ContentProps { background?: { grey?: boolean; }; small?: boolean; noPadding?: boolean; noPaddingBottom?: boolean; noPaddingTop?: boolean; isFullWidthOnLarge?: boolean; children?: ReactNode; } const ContentPackage: FC = ({ children, small = false, background = { grey: false }, noPadding = false, noPaddingBottom = false, noPaddingTop = false, isFullWidthOnLarge = false, }) => { return (
{children}
); }; const PackageTemplate: FC = ({ id, title, Image, ImageProps, titleDescription, description, notesTitle, notes, descriptionMore, price, originalPrice, priceLabelMessage, currencyIsoCode, ButtonToCheckout, duration, durationType, durationTypeText, durationLabel, faq, averageRating, rating, ratings, reviews, faqs, selectedOption, // TODO set by selectoin or a default partnerType, partnerMessage, partnerMessageDescription, name, handleRatingShowMoreClick, showMoreRatingsLabel, isLoadingRatings, ratingsLabel, campaign, }) => { const [showElement, setShowElement] = useState(false); const elementRef = useRef(); const roundToPrecision = (x, precision) => { var y = +x + (precision === undefined ? 0.5 : precision / 2); return y - (y % (precision === undefined ? 1 : +precision)); }; // Element scroll position useScrollPosition( ({ currPos }) => { if (currPos.y < 0) { setShowElement(true); } else { setShowElement(false); } }, [], elementRef, ); const ratingPrecise = roundToPrecision(averageRating, 0.5); const fullStars = ratingPrecise % 2 === 1 ? ratingPrecise : Math.floor(ratingPrecise); const halfStars = ratingPrecise % 2 === 1 ? 0 : 1; const strokedStars = 5 - fullStars - halfStars; return (
{campaign ? ( ) : ( )}
{campaign && (
)}

{title}

{originalPrice && (
)} {price && (
{' '} {' '} {' / '} {duration}{' '} {durationType === 'Minutes' ? 'Min.' : 'N/D'}
)}
{ButtonToCheckout && }
{ratings && ratings.count > 0 && (
{fullStars > 0 && [...Array(fullStars).keys()].map((rating, idx) => ( ))} {halfStars > 0 && [...Array(halfStars).keys()].map((rating, idx) => ( ))} {strokedStars > 0 && [...Array(strokedStars).keys()].map((rating, idx) => ( ))} {ratings && ratings.count} {ratingsLabel}
)} {partnerType.toLowerCase() === 'friend' && (
* {priceLabelMessage}
)}
{description &&

{description}

}

{descriptionMore && ( <>

{titleDescription}

    {duration && (
  • {durationLabel}: {duration} {durationTypeText}
  • )}
  • {partnerMessage}**
  • {descriptionMore && descriptionMore .split('\n') .map(line =>
  • {line}
  • )}
)} {notes && (

{notesTitle}

{notes}
)}
**{partnerMessageDescription}
{ratings && ratings.count > 0 && (

{ratingsLabel}

{ratings.items.map((rating, idx) => (
{[...Array(Math.floor(rating.rating))].map( (rating, idx) => { return ( ); }, )} {[...Array(Math.floor(5 - rating.rating))].map( (rating, idx) => { return ( ); }, )}
{rating.firstName}{' '} {new Date(rating.createdAt).toLocaleDateString( 'de-CH', )}
{rating.feedback}
))}
{!(ratings.count === ratings.items.length) && (
)}
)} {faqs && (

FAQ

{faqs.map(faq => (

{faq.answer}

))}
)}
{name}
{ButtonToCheckout && }
); }; export default PackageTemplate;