Skip to content

Commit

Permalink
WIP: Show login form when clicked on login button
Browse files Browse the repository at this point in the history
  • Loading branch information
harishmohanraj committed Apr 10, 2024
1 parent 4c1cca4 commit 2806f6d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 39 deletions.
1 change: 0 additions & 1 deletion app/src/client/Main.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ a {
-o-transition: max-height 0.5s;
transition: max-height 0.5s;
overflow: hidden;
max-height: 280px;
}

.custom-auth-wrapper div>a {
Expand Down
10 changes: 3 additions & 7 deletions app/src/client/auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function Auth({
const [errorMessage, setErrorMessage] = useState<ErrorMessage | null>(null);
const [successMessage, setSuccessMessage] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const [loginFlow, setLoginFlow] = useState(titles.signup);

// TODO(matija): this is called on every render, is it a problem?
// If we do it in useEffect(), then there is a glitch between the default color and the
Expand All @@ -79,10 +78,6 @@ function Auth({
const socialButtonsDirection =
socialLayout === 'vertical' ? 'vertical' : 'horizontal';

const changeHeaderText = (loginFlow: string) => {
setLoginFlow(loginFlow === 'signIn' ? titles.signup : titles.login);
};

return (
<div className={customTheme}>
<div>
Expand All @@ -95,7 +90,9 @@ function Auth({
/>
)}
{/* <HeaderText>{title}</HeaderText> */}
<p className='mt-7 text-2xl'>{loginFlow}</p>
<p className='mt-7 text-2xl'>
{state === 'signup' ? titles.signup : titles.login}
</p>
</div>

{/* {errorMessage && (
Expand All @@ -115,7 +112,6 @@ function Auth({
socialButtonsDirection={socialButtonsDirection}
additionalSignupFields={additionalSignupFields}
errorMessage={errorMessage}
changeHeaderText={changeHeaderText}
/>
)}
</AuthContext.Provider>
Expand Down
27 changes: 4 additions & 23 deletions app/src/client/auth/LoginSignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ export const LoginSignupForm = ({
socialButtonsDirection = 'horizontal',
additionalSignupFields,
errorMessage,
changeHeaderText,
}: {
state: 'login' | 'signup';
socialButtonsDirection?: 'horizontal' | 'vertical';
additionalSignupFields?: any;
errorMessage?: any;
changeHeaderText: any;
}) => {
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } =
useContext(AuthContext);
Expand Down Expand Up @@ -123,15 +121,6 @@ export const LoginSignupForm = ({
}
};

const toggleLoginFlow = () => {
const newLoginFlow = loginFlow === State.Login ? State.Signup : State.Login;
setLoginFlow(newLoginFlow);
setTocChecked(false);
setMarketingEmailsChecked(false);
setErrorMessage(null);
changeHeaderText(loginFlow);
};

const googleBtnText =
loginFlow === State.Login ? 'Sign in with Google' : 'Sign up with Google';

Expand Down Expand Up @@ -193,22 +182,14 @@ export const LoginSignupForm = ({
</SocialAuth>
<div className='flex items-center justify-center'>
<span className='text-sm block'>
{/* {loginFlow === State.Login
{loginFlow === State.Login
? "Don't have an account? "
: 'Already have an account? '} */}
{/* <a
className='no-underline hover:underline cursor-pointer'
onClick={toggleLoginFlow}
>
{loginFlow === State.Login ? State.Signup : State.Login}
</a> */}
: 'Already have an account? '}
<Link
to={loginFlow === State.Login ? '/signup' : '/login'}
className='underline'
className='no-underline hover:underline cursor-pointer'
>
{loginFlow === State.Login
? "Don't have an account? "
: 'Already have an account? '}
{loginFlow === State.Login ? 'Sign up' : 'Sign in'}
</Link>
</span>
</div>
Expand Down
9 changes: 1 addition & 8 deletions app/src/client/components/TosAndMarketingEmailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ const TosAndMarketingEmailsModal = () => {
}
};

const customStyle = errorMessage
? { maxHeight: '400px' }
: { maxHeight: '280px' };

const isAccountPage = useMemo(() => {
return location.pathname.startsWith('/account');
}, [location]);
Expand All @@ -70,10 +66,7 @@ const TosAndMarketingEmailsModal = () => {
{!isAccountPage && <AppNavBar />}

<div className='flex items-center justify-center z-50 p-16 backdrop-blur-sm bg-captn-light-cream/30 mt-16'>
<div
className='toc-marketing-container bg-captn-dark-blue rounded-lg shadow-lg p-8 m-4 max-w-xl mx-auto'
style={customStyle}
>
<div className='toc-marketing-container bg-captn-dark-blue rounded-lg shadow-lg p-8 m-4 max-w-xl mx-auto'>
<div className='inner-wrapper'>
<h2 className='text-xl font-bold mb-4 text-captn-light-cream'>
Almost there...
Expand Down

0 comments on commit 2806f6d

Please sign in to comment.