All files / src/components/Booking BookingPlaces.tsx

100% Statements 9/9
50% Branches 2/4
100% Functions 3/3
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48              4x   4x 2x 2x   2x                                         4x 1x   1x         2x          
import React, { FC } from 'react';
import { useTranslation } from 'react-i18next';
import { KsCard, Slider } from 'ag-ems-ui-library';
import { formatToPrice } from '../../helpers';
import { LocalizedLink as Link } from 'gatsby-theme-i18n'
import { GatsbyImage, getImage } from 'gatsby-plugin-image';
 
const styles = require('./Booking.module.css');
 
export const BookingPlace: FC<{ product: any }> = ({ product }) => {
  const { t } = useTranslation();
  const image = getImage(product.thumbnail);
 
  return (
    <KsCard
      classes={styles.BookingPlace}
      link={'/' + product.slug}
      image={
        image ? <GatsbyImage image={image} alt={product.name} /> : null
      }
      linkComponent={Link}
      desktopView={false}
    >
      <p className={styles.BookingPlaceName}>{product.name}</p>
      <p className={styles.BookingPlacePrice}>
        {`${t('from')} ${formatToPrice(product.price)}`}
      </p>
    </KsCard>
  );
};
 
export const BookingPlaces: FC<{
  products: any[],
  title?: string
}> = ({ products, title }) => {
  const { t } = useTranslation();
 
  return <div className={styles.BookingPlaces}>
    <h3 className={styles.BookingSubtitle}>{title || t('experienceCrosslinks')}</h3>
    <div className={styles.BookingPlacesContent}>
      <Slider breakpoint={1025} spaceBetween={20}>
        {products.map(product => (
          <BookingPlace key={product.sku} product={product} />
        ))}
      </Slider>
    </div>
  </div>;
};