import { Button } from '@cloud-ru/ds-button'; import { Carousel } from '@cloud-ru/ds-carousel'; import { CrossSVG } from '@cloud-ru/ds-icons/interface/system'; import { InfoBlock } from '@cloud-ru/ds-info-block'; import { Typography } from '@cloud-ru/ds-typography'; import cn from 'classnames'; import { ReactNode } from 'react'; import { CONTENT_STATE, TEST_IDS } from '../../constants'; import { NoteItemProps, ReleaseNotesContentState, Surface } from '../../types'; import { NoteItem, NoteItemSkeleton } from '../NoteItem'; import styles from './styles.module.scss'; export type ReleaseNotesContentProps = { /** Визуальное состояние */ contentState: ReleaseNotesContentState; /** Новости */ items: NoteItemProps[]; /** Состояние загрузки */ loading?: boolean; /** Текущая страница, zero-based */ pageIndex: number; /** Поверхность */ surface: Surface; /** Заголовок no-data */ noDataTitle: string; /** Описание no-data */ noDataDescription: string; /** Заголовок ошибки */ errorTitle: string; /** Описание ошибки */ errorDescription: string; /** Label retry-кнопки */ retryLabel: string; /** Смена страницы */ onPageChange(pageIndex: number): void; /** Повторная загрузка */ onDataErrorRetryClick?(): void; }; function InfoBlockDescription({ children }: { children: ReactNode }) { return ( {children} ); } export function ReleaseNotesContent({ contentState, items, loading, pageIndex, surface, noDataTitle, noDataDescription, errorTitle, errorDescription, retryLabel, onPageChange, onDataErrorRetryClick, }: ReleaseNotesContentProps) { const total = items.length; const hasItems = total > 0; if (loading) { return (
); } if (contentState === CONTENT_STATE.Error) { return (
{errorDescription}} icon={{ icon: CrossSVG, appearance: 'neutral', background: true }} data-test-id={TEST_IDS.releaseNotesError} footer={
); } if (contentState === CONTENT_STATE.NoData || !hasItems) { return (
{noDataDescription}} data-test-id={TEST_IDS.releaseNotesNoData} />
); } return (
{items.map(item => ( ))}
); }