2019-09-26 18:28:08 +02:00
|
|
|
// @flow
|
2020-05-21 17:38:28 +02:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
|
|
|
import * as ICONS from 'constants/icons';
|
2019-09-26 18:28:08 +02:00
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import ClaimList from 'component/claimList';
|
|
|
|
import Page from 'component/page';
|
|
|
|
import Button from 'component/button';
|
|
|
|
import YoutubeTransferStatus from 'component/youtubeTransferStatus';
|
2019-11-15 21:48:57 +01:00
|
|
|
import Spinner from 'component/spinner';
|
2020-05-21 17:38:28 +02:00
|
|
|
import Card from 'component/common/card';
|
2020-06-29 21:54:07 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
2019-09-26 18:28:08 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
channels: Array<ChannelClaim>,
|
2020-06-21 18:51:06 +02:00
|
|
|
channelUrls: Array<string>,
|
2019-09-26 18:28:08 +02:00
|
|
|
fetchChannelListMine: () => void,
|
|
|
|
fetchingChannels: boolean,
|
|
|
|
youtubeChannels: ?Array<any>,
|
2019-12-06 20:42:44 +01:00
|
|
|
openModal: string => void,
|
2019-09-26 18:28:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function ChannelsPage(props: Props) {
|
2020-06-21 18:51:06 +02:00
|
|
|
const { channels, channelUrls, fetchChannelListMine, fetchingChannels, youtubeChannels, openModal } = props;
|
2019-09-26 18:28:08 +02:00
|
|
|
const hasYoutubeChannels = youtubeChannels && Boolean(youtubeChannels.length);
|
2019-12-09 16:16:49 +01:00
|
|
|
const hasPendingChannels = channels && channels.some(channel => channel.confirmations < 0);
|
2019-09-26 18:28:08 +02:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
fetchChannelListMine();
|
2019-10-03 23:40:54 +02:00
|
|
|
}, [fetchChannelListMine, hasPendingChannels]);
|
2019-09-26 18:28:08 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Page>
|
2020-06-30 07:51:15 +02:00
|
|
|
<div className="card-stack">
|
|
|
|
{hasYoutubeChannels && <YoutubeTransferStatus hideChannelLink />}
|
|
|
|
|
|
|
|
{channelUrls && Boolean(channelUrls.length) && (
|
|
|
|
<Card
|
|
|
|
title={__('Your Channels')}
|
|
|
|
titleActions={
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
button="secondary"
|
|
|
|
icon={ICONS.CHANNEL}
|
|
|
|
label={__('New Channel')}
|
|
|
|
navigate={`/$/${PAGES.CHANNEL_NEW}`}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
isBodyList
|
|
|
|
body={<ClaimList isCardBody loading={fetchingChannels} uris={channelUrls} />}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
2019-09-26 18:28:08 +02:00
|
|
|
|
2020-06-21 18:51:06 +02:00
|
|
|
{!(channelUrls && channelUrls.length) && (
|
2019-11-15 21:48:57 +01:00
|
|
|
<React.Fragment>
|
|
|
|
{!fetchingChannels ? (
|
|
|
|
<section className="main--empty">
|
|
|
|
<div className=" section--small">
|
|
|
|
<h2 className="section__title--large">{__('No Channels Created Yet')}</h2>
|
|
|
|
|
|
|
|
<div className="section__actions">
|
2019-12-06 20:42:44 +01:00
|
|
|
<Button button="primary" label={__('New Channel')} onClick={() => openModal(MODALS.CREATE_CHANNEL)} />
|
2019-11-15 21:48:57 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
) : (
|
|
|
|
<section className="main--empty">
|
|
|
|
<div className=" section--small">
|
|
|
|
<h2 className="section__title--small">
|
|
|
|
{__('Checking for channels')}
|
|
|
|
<Spinner type="small" />
|
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
)}
|
|
|
|
</React.Fragment>
|
2019-09-26 18:28:08 +02:00
|
|
|
)}
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|