Feat/navigate to signup if email does not exist (#540)

* Add userExists route

* Fix demo mode for login

* Improve sign in/up flow

* Remove redundant password length constraint

* Fix test
This commit is contained in:
Emilien Chauvet
2023-07-08 15:02:39 -07:00
committed by GitHub
parent 36ace6cc03
commit 9cd5f7c057
10 changed files with 123 additions and 20 deletions

View File

@ -16,6 +16,7 @@ import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysSc
import { MainButton } from '@/ui/components/buttons/MainButton';
import { TextInput } from '@/ui/components/inputs/TextInput';
import { SubSectionTitle } from '@/ui/components/section-titles/SubSectionTitle';
import { useCheckUserExistsQuery } from '~/generated/graphql';
const StyledContentContainer = styled.div`
width: 100%;
@ -84,11 +85,20 @@ export function PasswordLogin() {
[handleLogin],
);
const { loading, data } = useCheckUserExistsQuery({
variables: {
email: authFlowUserEmail,
},
});
return (
<>
<Logo />
<Title>Welcome to Twenty</Title>
<SubTitle>Enter your credentials to sign in</SubTitle>
<SubTitle>
Enter your credentials to sign{' '}
{data?.checkUserExists.exists ? 'in' : 'up'}
</SubTitle>
<StyledAnimatedContent>
<StyledContentContainer>
<StyledSectionContainer>
@ -115,7 +125,7 @@ export function PasswordLogin() {
<MainButton
title="Continue"
onClick={handleLogin}
disabled={!authFlowUserEmail || !internalPassword}
disabled={!authFlowUserEmail || !internalPassword || loading}
fullWidth
/>
</StyledButtonContainer>