import React, { useCallback, useState } from 'react'; import { Link } from 'react-router-dom'; import ReactSwipeableViews from 'react-swipeable-views'; import EventPreview from 'soapbox/components/event-preview'; import { Card, Icon } from 'soapbox/components/ui'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetStatus } from 'soapbox/selectors'; import PlaceholderEventPreview from '../../placeholder/components/placeholder-event-preview'; import type { OrderedSet as ImmutableOrderedSet } from 'immutable'; const Event = ({ id }: { id: string }) => { const getStatus = useCallback(makeGetStatus(), []); const status = useAppSelector(state => getStatus(state, { id })); if (!status) return null; return ( ); }; interface IEventCarousel { statusIds: ImmutableOrderedSet isLoading?: boolean | null emptyMessage: React.ReactNode } const EventCarousel: React.FC = ({ statusIds, isLoading, emptyMessage }) => { const [index, setIndex] = useState(0); const handleChangeIndex = (index: number) => { setIndex(index % statusIds.size); }; if (statusIds.size === 0) { if (isLoading) { return ; } return ( {emptyMessage} ); } return (
{index !== 0 && (
)} {statusIds.map(statusId => )} {index !== statusIds.size - 1 && (
)}
); }; export default EventCarousel;