Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

2.0 KB
Raw Blame
import { useValues } from 'kea'

import { LemonButton } from 'lib/lemon-ui/LemonButton'

import { authLogic } from '../authLogic'
import { loginLogic } from '../loginLogic'
import { signupLogic } from '../signupLogic'

export function EmailStepSubmitButton(): JSX.Element | null {
    const { entry, step, isEmailSubmitting, isLoginPasswordHidden } = useValues(authLogic)
    const { isLoginSubmitting } = useValues(loginLogic)
    const { validatedPassword, passkeyRegistered, isSignupPanelAuthSubmitting } = useValues(signupLogic)

    if (step === 'login') {
        return isLoginPasswordHidden ? null : (
            <LemonButton
                type="primary"
                size="large"
                center
                fullWidth
                htmlType="submit"
                data-attr="password-login"
                loading={isLoginSubmitting}
            >
                Log in
            </LemonButton>
        )
    }
    if (step === 'signup_credentials') {
        return (
            <LemonButton
                type="primary"
                size="large"
                center
                fullWidth
                htmlType="submit"
                // pinned: Playwright and the signup funnel select the account creation submit by this
                data-attr="signup-auth-continue"
                loading={isSignupPanelAuthSubmitting}
                disabledReason={
                    !passkeyRegistered && validatedPassword.feedback ? validatedPassword.feedback : undefined
                }
            >
                Create account
            </LemonButton>
        )
    }
    return (
        <LemonButton
            type="primary"
            size="large"
            center
            fullWidth
            htmlType="submit"
            // pinned: `signup-start` is the signup funnel's existing first-step attribute
            data-attr={entry === 'signup' ? 'signup-start' : 'login-email-continue'}
            loading={isEmailSubmitting}
        >
            Continue
        </LemonButton>
    )
}