Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions frontend/web/components/GoogleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import { Icon } from './icons'

type GoogleButtonProps = {
className?: string
ready: boolean
onSuccess?: (
tokenResponse: Omit<
TokenResponse,
'error' | 'error_description' | 'error_uri'
>,
) => void
}
const GoogleButton: FC<GoogleButtonProps> = ({ className, onSuccess }) => {
const GoogleButton: FC<GoogleButtonProps> = ({
className,
onSuccess,
ready,
}) => {
const login = useGoogleLogin({
onSuccess: (tokenResponse) => {
onSuccess?.(tokenResponse)
Expand All @@ -24,7 +29,8 @@ const GoogleButton: FC<GoogleButtonProps> = ({ className, onSuccess }) => {
className={className}
theme='secondary'
key='google'
onClick={() => login()}
disabled={!ready}
onClick={() => ready && login()}
Comment thread
kyle-ssg marked this conversation as resolved.
>
<Icon name='google' />
Google
Expand Down
4 changes: 4 additions & 0 deletions frontend/web/components/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import useSignupExperiment from 'common/useSignupExperiment'
const HomePage: React.FC = () => {
const history = useHistory()
const location = useLocation()
const [googleReady, setGoogleReady] = useState(false)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
const [allRequirementsMet, setAllRequirementsMet] = useState(false)
const [email, setEmail] = useState('')
const [firstName, setFirstName] = useState('')
Expand Down Expand Up @@ -231,9 +232,12 @@ const HomePage: React.FC = () => {
clientId={
JSON.parse(Utils.getFlagsmithValue('oauth_google')).clientId
}
onScriptLoadSuccess={() => setGoogleReady(true)}
onScriptLoadError={() => setGoogleReady(false)}
>
<GoogleButton
className='w-100'
ready={googleReady}
onSuccess={(e) => {
document.location.href = `${
document.location.origin
Expand Down
Loading