2019-12-23 01:03:44 +00:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { useStoreState } from 'easy-peasy';
|
|
|
|
import { ApplicationStore } from '@/state';
|
2020-07-03 23:37:26 +01:00
|
|
|
import tw from 'twin.macro';
|
2022-07-02 23:53:03 +01:00
|
|
|
import { Button } from '@/components/elements/button/index';
|
|
|
|
import SetupTOTPModal from '@/components/dashboard/forms/SetupTOTPModal';
|
|
|
|
import DisableTwoFactorModal from '@/components/dashboard/forms/DisableTwoFactorModal';
|
2019-12-23 01:03:44 +00:00
|
|
|
|
|
|
|
export default () => {
|
2022-07-02 23:53:03 +01:00
|
|
|
const [visible, setVisible] = useState<'enable' | 'disable' | null>(null);
|
2021-05-16 20:35:49 +01:00
|
|
|
const isEnabled = useStoreState((state: ApplicationStore) => state.user.data!.useTotp);
|
2019-12-23 01:03:44 +00:00
|
|
|
|
2021-05-16 20:35:49 +01:00
|
|
|
return (
|
2019-12-23 01:03:44 +00:00
|
|
|
<div>
|
2022-07-02 23:53:03 +01:00
|
|
|
<SetupTOTPModal open={visible === 'enable'} onClose={() => setVisible(null)} />
|
|
|
|
<DisableTwoFactorModal visible={visible === 'disable'} onModalDismissed={() => setVisible(null)} />
|
2020-07-03 23:37:26 +01:00
|
|
|
<p css={tw`text-sm`}>
|
2022-06-26 20:13:52 +01:00
|
|
|
{isEnabled
|
2022-07-02 23:53:03 +01:00
|
|
|
? 'Two-step verification is currently enabled on your account.'
|
|
|
|
: 'You do not currently have two-step verification enabled on your account. Click the button below to begin configuring it.'}
|
2019-12-23 01:03:44 +00:00
|
|
|
</p>
|
2020-07-03 23:37:26 +01:00
|
|
|
<div css={tw`mt-6`}>
|
2022-07-02 23:53:03 +01:00
|
|
|
{isEnabled ? (
|
|
|
|
<Button.Danger onClick={() => setVisible('disable')}>Disable Two-Step</Button.Danger>
|
|
|
|
) : (
|
|
|
|
<Button onClick={() => setVisible('enable')}>Enable Two-Step</Button>
|
|
|
|
)}
|
2019-12-23 01:03:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-05-16 20:35:49 +01:00
|
|
|
);
|
2019-12-23 01:03:44 +00:00
|
|
|
};
|