import React, { FC, MouseEventHandler, useEffect } from 'react'; import { Redirect } from 'react-router-dom'; import { FormattedMessage as Message } from 'react-intl'; import { Helmet } from 'react-helmet-async'; import { useReduxSelector } from 'app/functions'; import { Button } from 'app/components/ui/form'; import copy from 'app/services/copy'; import styles from './finish.scss'; interface Props { appName: string; code?: string; state: string; displayCode?: boolean; success?: boolean; } const Finish: FC = () => { const { client, oauth } = useReduxSelector((state) => state.auth); const onCopyClick: MouseEventHandler = (event) => { event.preventDefault(); copy(oauth!.code!); }; let authData: string | undefined; if (oauth && 'state' in oauth.params) { authData = JSON.stringify({ auth_code: oauth.code, state: oauth.params.state, }); } useEffect(() => { if (authData) { history.pushState(null, document.title, `#${authData}`); } }, []); if (!client || !oauth) { return ; } return (
{authData && } {oauth.success ? (
{client.name}, }} />
{oauth.displayCode ? (
{oauth.code}
) : (
)}
) : (
{client.name}, }} />
)}
); }; export default Finish;