import { useEffect, useState } from 'react'; import { SmallItemCarousel, ExitIcon, ErrorItemCarousel } from './styles'; import Backdrop from '@mui/material/Backdrop'; import SmallCarousel from './SmallCarousel'; import { EmptyStateCarouselProps, NEXT } from './types'; import BigCarousel from './BigCarousel'; import { ASSETS_URL } from '../../consts/common'; export const EmptyStateCarousel = ({ items, isSmall, fallBackImg, imgClickEvent, leftClickEvent, rightClickEvent, vidoStartEvent, className, width, isError }: EmptyStateCarouselProps) => { const [open, setOpen] = useState(false); const [index, setIndex] = useState(0); const handleClose = (e: { stopPropagation: () => void }) => { setIndex(0); setOpen(false); }; const handleToggle = (i?: number) => { setIndex(i || 0); setOpen(!open); }; const handleBigCarousel = (dir: string) => { if (dir === NEXT) { if (items[index + 1]) { setIndex(index + 1); } else setIndex(0); } else { if (index > 0) { setIndex(index - 1); } else setIndex(items.length - 1); } }; useEffect(() => { const close = (e: KeyboardEvent) => { if (e.code === 'Escape') { setIndex(0); setOpen(false); } }; window.addEventListener('keydown', close); return () => window.removeEventListener('keydown', close); }, []); return (
theme.zIndex.drawer + 1, opacity: '0.8 !important', backgroundColor: '#000000' }} transitionDuration={0} open={open} onClick={handleClose} > {items ? ( {items.map((item, i) => ( { imgClickEvent(); handleToggle(i); }} key={i} img={item.imgUrl} /> ))} ) : ( handleToggle()} img={isError ? fallBackImg : ''} /> )}
); };