import React, { useState } from 'react'; import { black, Clickable, Flex, secondary, Text, Title, Wrapper } from 'dot-design-system'; import CircleIconButton from '../elements/CircleIconButton'; import { useStoreActions, useStoreState } from '../store/store.hooks'; import { ajaxAction } from '../ajax/ajax.utils'; import { AjaxState } from '../ajax/ajax.model'; // @ts-ignore import mobilesImgSrc from '../assets/dot-mobiles.png'; import { getGlobal } from '../utils/wp'; interface Props {} function CreateAccount({}: Props) { const hasToken = useStoreState((state) => state.authentication.hasToken); const setToken = useStoreActions((actions) => actions.authentication.setToken); const [isLoading, setIsLoading] = useState(false); const handleClick = async (e: any) => { e.preventDefault(); if (!hasToken) { const anchor = e.target.closest('a'); if (anchor) { window.open(anchor.href, 'DOT Audiences Portal', 'resizable,height=800,width=800'); } } setIsLoading(true); const result = await ajaxAction({ action: 'dot_press_delete_token', method: 'post' }); if (result !== AjaxState.Error) { setToken(''); } setIsLoading(false); }; return ( {hasToken && ( DOT Account Connected (Click{' '} here {' '} to disconnect) )} {!hasToken && ( Click here to Create Account/Login )} ); } export default CreateAccount;