2022-10-09 01:05:52 +03:00
|
|
|
import { Divider } from 'antd';
|
|
|
|
import { ClockCircleOutlined } from '@ant-design/icons';
|
2022-09-07 10:00:28 +03:00
|
|
|
import { FC } from 'react';
|
2022-10-09 01:05:52 +03:00
|
|
|
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
2022-09-07 10:00:28 +03:00
|
|
|
import styles from './OfflineBanner.module.scss';
|
2022-10-09 01:05:52 +03:00
|
|
|
import { FollowButton } from '../../action-buttons/FollowButton';
|
|
|
|
import { NotifyButton } from '../../action-buttons/NotifyButton';
|
2022-05-26 08:52:27 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type OfflineBannerProps = {
|
2022-10-09 01:05:52 +03:00
|
|
|
streamName: string;
|
|
|
|
customText?: string;
|
|
|
|
lastLive?: Date;
|
|
|
|
notificationsEnabled: boolean;
|
|
|
|
fediverseAccount?: string;
|
|
|
|
onNotifyClick?: () => void;
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
2022-05-26 08:52:27 +03:00
|
|
|
|
2022-10-09 01:05:52 +03:00
|
|
|
export const OfflineBanner: FC<OfflineBannerProps> = ({
|
|
|
|
streamName,
|
|
|
|
customText,
|
|
|
|
lastLive,
|
|
|
|
notificationsEnabled,
|
|
|
|
fediverseAccount,
|
|
|
|
onNotifyClick,
|
|
|
|
}) => {
|
|
|
|
let text;
|
|
|
|
if (customText) {
|
|
|
|
text = customText;
|
|
|
|
} else if (!customText && notificationsEnabled && fediverseAccount) {
|
|
|
|
text = `This stream is offline. You can be notified the next time ${streamName} goes live or follow ${fediverseAccount} on the Fediverse.`;
|
|
|
|
} else if (!customText && notificationsEnabled) {
|
|
|
|
text = `This stream is offline. Be notified the next time ${streamName} goes live.`;
|
|
|
|
} else {
|
|
|
|
text = `This stream is offline. Check back soon!`;
|
|
|
|
}
|
2022-05-26 08:52:27 +03:00
|
|
|
|
2022-10-09 01:05:52 +03:00
|
|
|
return (
|
|
|
|
<div className={styles.outerContainer}>
|
|
|
|
<div className={styles.innerContainer}>
|
|
|
|
<div className={styles.header}>{streamName}</div>
|
|
|
|
<Divider className={styles.separator} />
|
|
|
|
<div className={styles.bodyText}>{text}</div>
|
|
|
|
{lastLive && (
|
|
|
|
<div className={styles.lastLiveDate}>
|
|
|
|
<ClockCircleOutlined className={styles.clockIcon} />
|
|
|
|
{`Last live ${formatDistanceToNow(new Date(lastLive))} ago.`}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<div className={styles.footer}>
|
|
|
|
{fediverseAccount && <FollowButton />}
|
|
|
|
|
2022-10-10 00:45:42 +03:00
|
|
|
{notificationsEnabled && <NotifyButton text="Notify when live" onClick={onNotifyClick} />}
|
2022-10-09 01:05:52 +03:00
|
|
|
</div>
|
2022-05-26 08:52:27 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-09 01:05:52 +03:00
|
|
|
);
|
|
|
|
};
|