2020-06-29 21:54:07 +02:00
|
|
|
// @flow
|
2020-08-26 18:24:07 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
2020-06-29 21:54:07 +02:00
|
|
|
import React from 'react';
|
2021-12-08 23:48:02 +01:00
|
|
|
import ChannelForm from 'component/channelForm';
|
2020-06-29 21:54:07 +02:00
|
|
|
import Page from 'component/page';
|
2020-08-25 21:54:06 +02:00
|
|
|
import { useHistory } from 'react-router';
|
2020-08-26 19:19:03 +02:00
|
|
|
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,
|
2021-04-03 08:21:54 +02:00
|
|
|
claimConfirmEmailReward: () => void,
|
|
|
|
isAuthenticated: boolean,
|
2020-06-29 21:54:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function ChannelNew(props: Props) {
|
2021-04-03 08:21:54 +02:00
|
|
|
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;
|
|
|
|
|
2021-04-03 08:21:54 +02:00
|
|
|
React.useEffect(() => {
|
|
|
|
if (isAuthenticated && emptyBalance) {
|
|
|
|
claimConfirmEmailReward();
|
|
|
|
}
|
|
|
|
}, [isAuthenticated, claimConfirmEmailReward, emptyBalance]);
|
|
|
|
|
2020-06-29 21:54:07 +02:00
|
|
|
return (
|
2020-08-26 18:24:07 +02:00
|
|
|
<Page noSideNavigation noFooter backout={{ title: __('Create a channel'), backLabel: __('Cancel') }}>
|
2020-08-26 19:19:03 +02:00
|
|
|
{emptyBalance && <YrblWalletEmpty />}
|
2020-08-25 21:54:06 +02:00
|
|
|
|
2021-12-08 23:48:02 +01:00
|
|
|
<ChannelForm
|
2021-03-03 19:50:16 +01:00
|
|
|
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;
|