import React from 'react'; import clsx from 'clsx'; import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Button, } from 'reactstrap'; import { useTranslation } from 'react-i18next'; import { fromEvent } from 'rxjs'; import { useAvatarUrl } from '../data/user'; import { timelineVisibilityTooltipTranslationMap } from '../data/timeline'; import { TimelineCardComponentProps } from './TimelinePageTemplateUI'; export type OrdinaryTimelineManageItem = 'delete'; export type TimelineInfoCardProps = TimelineCardComponentProps< OrdinaryTimelineManageItem >; const TimelineInfoCard: React.FC = (props) => { const { onHeight, onManage } = props; const { t } = useTranslation(); const avatarUrl = useAvatarUrl(props.timeline.owner.username); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const containerRef = React.useRef(null!); const notifyHeight = React.useCallback((): void => { if (onHeight) { onHeight(containerRef.current.getBoundingClientRect().height); } }, [onHeight]); React.useEffect(() => { const subscription = fromEvent(window, 'resize').subscribe(notifyHeight); return () => subscription.unsubscribe(); }); const [manageDropdownOpen, setManageDropdownOpen] = React.useState( false ); const toggleManageDropdown = React.useCallback( (): void => setManageDropdownOpen((old) => !old), [] ); return (

{props.timeline.name}

{props.timeline.owner.nickname} @{props.timeline.owner.username}

{props.timeline.description}

{t(timelineVisibilityTooltipTranslationMap[props.timeline.visibility])}
{onManage != null ? ( {t('timeline.manage')} onManage('property')}> {t('timeline.manageItem.property')} {t('timeline.manageItem.member')} onManage('delete')} > {t('timeline.manageItem.delete')} ) : ( )}
); }; export default TimelineInfoCard;