import React, { Fragment, FunctionComponent } from 'react'; import Card from '../../blocks/Card'; import DefaultLink from '../../blocks/Link'; import Button from '../../blocks/Button'; import classname from 'classnames'; import css from './index.module.css'; import { useSpring, animated } from 'react-spring'; import { getAmountWithCurrency, getReduction } from '../../helpers/priceHelper'; import Discount from '../../blocks/Discount'; export interface PackageListProps { items?: { id: string; isVisible: boolean; }[]; isSelected?: boolean; isLoading?: boolean; hasAllItemsLoaded?: boolean; setIsLoading?: (isLoading) => void; updatePackageItems?: (items) => void; showMoreText?: string; emptyMessage: string; pagination: { hasAllItemsLoaded: boolean; isLoading: boolean; setIsLoading: (isLoading) => void; showMoreText: string; }; } export const PackageListItem = ({ item, isSelected }): JSX.Element => { const Link = item.Link || DefaultLink; const animationProps = useSpring({ to: { opacity: isSelected ? 1 : 0 }, from: { opacity: 0 }, }); return ( {item?.type === 'Brand Box' ? (
) : (
{getAmountWithCurrency( item.PriceProps.amount, item.PriceProps.currency, item.partnerType, )}   {` /${item.duration} ${item.durationType}`} {item.PriceProps.originalAmount && ( )}
)} ); }; const PackageList: FunctionComponent = ({ items, emptyMessage = '', updatePackageItems, pagination, isSelected, }) => { const { hasAllItemsLoaded, isLoading, setIsLoading } = pagination; return (
{items && items.map(item => { if (!item.isVisible) return null; return ( ); })}
{hasAllItemsLoaded ? (
{hasAllItemsLoaded && ( )}
) : (
)}
); }; export default PackageList;