lbry-desktop/ui/page/channelNew/view.jsx

43 lines
1.2 KiB
React
Raw Normal View History

2020-06-29 21:54:07 +02:00
// @flow
import * as PAGES from 'constants/pages';
2020-06-29 21:54:07 +02:00
import React from 'react';
import ChannelEdit from 'component/channelEdit';
import Page from 'component/page';
2020-08-25 21:54:06 +02:00
import { useHistory } from 'react-router';
import YrblWalletEmpty from 'component/yrblWalletEmpty';
2020-06-29 21:54:07 +02:00
type Props = {
2020-08-25 21:54:06 +02:00
balance: number,
claimConfirmEmailReward: () => void,
isAuthenticated: boolean,
2020-06-29 21:54:07 +02:00
};
function ChannelNew(props: Props) {
const { balance, claimConfirmEmailReward, isAuthenticated } = props;
2020-08-25 21:54:06 +02:00
const { push, location } = useHistory();
const urlSearchParams = new URLSearchParams(location.search);
const redirectUrl = urlSearchParams.get('redirect');
const emptyBalance = balance === 0;
React.useEffect(() => {
if (isAuthenticated && emptyBalance) {
claimConfirmEmailReward();
}
}, [isAuthenticated, claimConfirmEmailReward, emptyBalance]);
2020-06-29 21:54:07 +02:00
return (
<Page noSideNavigation noFooter backout={{ title: __('Create a channel'), backLabel: __('Cancel') }}>
{emptyBalance && <YrblWalletEmpty />}
2020-08-25 21:54:06 +02:00
<ChannelEdit
disabled={emptyBalance}
onDone={() => {
push(redirectUrl || `/$/${PAGES.CHANNELS}`);
}}
/>
2020-06-29 21:54:07 +02:00
</Page>
);
}
2020-08-25 21:54:06 +02:00
export default ChannelNew;