import React, { FC, ReactNode } from 'react'; import css from '../../blocks/ModalRedesign/index.module.css'; import { Category } from '../PackageCategoryTab'; import { Button } from '../../index'; import IconLoader from '../../blocks/IconLoader'; import ArrowSVG from '../../assets/icons/icon-arrow-left.svg'; import Link from '../../blocks/Link'; import ModalRedesign from '../../blocks/ModalRedesign'; export interface CategoryModalProps { isOpen?: boolean; isLoading?: boolean; error?: string; children?: ReactNode; actions?: ReactNode; title?: string; selectedCategory: Category; onRequestClose: () => void; handleSelect: (slug: string) => void; Translations?: { showAll: string; showServices: string; title: string; }; } const CategoryModal: FC = ({ isOpen, selectedCategory, onRequestClose, handleSelect, Translations, ...rest }) => { const sortSubCategoriesByScore = (a, b): number => { if (!!a.promotionScore && !!b.promotionScore) { return a.promotionScore > b.promotionScore ? -1 : 1; } if (!a.promotionScore && !b.promotionScore) { return 0; } if (!a.promotionScore) { return b.promotionScore > 0 ? 1 : -1; } if (!b.promotionScore) { return a.promotionScore > 0 ? -1 : 1; } return 0; }; return ( {!!selectedCategory && ( <>
{selectedCategory.name}

{Translations?.title}

{selectedCategory.subcategories .sort(sortSubCategoriesByScore) .map((item, _) => { return (

{item.name}

{item.description}
); })}
)} { handleSelect('all'); }} className={css.modal__showAll} > {Translations?.showAll}
); }; export default CategoryModal;