import React from 'react'; import { CatalogParams, HeightEqualizer, HeightEqualizerElement, HeightEqualizerElementProps } from '@thoughtindustries/catalog/src/core'; import { CatalogResultItem, CatalogResultsProps, PriceFormatFn } from '@thoughtindustries/catalog/src/types'; import ItemLinkWrapper from '@thoughtindustries/catalog/src/variants/display-type-results/item-link-wrapper'; import ItemAssetBlock from './catalog-item-asset-block'; import ItemRibbon from '@thoughtindustries/catalog/src/variants/display-type-results/item-ribbon'; import clsx from 'clsx'; import { limitText } from '@thoughtindustries/catalog/src/variants/display-type-results/utilities'; type DisplayTypeResultsGridProps = Pick & Pick & { items: CatalogResultItem[]; priceFormatFn: PriceFormatFn; numberOfContentItems: number | undefined; }; type DisplayTypeResultsGridItemProps = Omit & { item: CatalogResultItem; }; const HeightEqualizerElementWrapper = ({ className, children, ...restProps }: HeightEqualizerElementProps) => { // stylings const baseClassnames = 'overflow-hidden block transition-all'; return ( {children} ); }; const ItemTitleBlock = ({ title }: { title: string }) => (
{title}
); const ItemSourceBlock = ({ contentTypeLabel, courseStartDate }: { contentTypeLabel?: string; courseStartDate?: string; }) => (

{courseStartDate && ( {contentTypeLabel} )}

); const ItemCtaBlock = ({ isActive, callToAction }: { isActive?: boolean; callToAction?: string; }) => { if (isActive) { return ( {callToAction} ); } return {callToAction}; }; const DisplayTypeResultsGridItem = ({ onClick, displayStartDateEnabled, item }: DisplayTypeResultsGridItemProps): JSX.Element => { const { asset, title, description, isActive, ribbon, courseStartDate, contentTypeLabel, callToAction, timeZone } = item; // derived values const displayCourseStartDate = displayStartDateEnabled ? courseStartDate : undefined; return (
  • <>
    {ribbon && }
    {title && }
    {description && limitText(description, 75)}

  • ); }; const DisplayTypeResultsGrid = ({ items, ...restProps }: DisplayTypeResultsGridProps): JSX.Element => { let contentItems; if (restProps.numberOfContentItems) { contentItems = items .slice(0, restProps.numberOfContentItems) .filter(({ isNotCompleted }) => !isNotCompleted) .map((item, index) => ( )); } else { contentItems = items .filter(({ isNotCompleted }) => !isNotCompleted) .map((item, index) => ( )); } return (
      {contentItems}
    ); }; DisplayTypeResultsGrid.displayName = 'DisplayTypeResultsGrid'; export default DisplayTypeResultsGrid;