|
|
@ -4,6 +4,10 @@ import { TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt'; |
|
|
|
import { httpGet } from '../../lib/http'; |
|
|
|
import { httpGet } from '../../lib/http'; |
|
|
|
import { Spinner } from '../ReactIcons/Spinner.tsx'; |
|
|
|
import { Spinner } from '../ReactIcons/Spinner.tsx'; |
|
|
|
import { GoogleIcon } from '../ReactIcons/GoogleIcon.tsx'; |
|
|
|
import { GoogleIcon } from '../ReactIcons/GoogleIcon.tsx'; |
|
|
|
|
|
|
|
import { |
|
|
|
|
|
|
|
getStoredUtmParams, |
|
|
|
|
|
|
|
triggerUtmRegistration, |
|
|
|
|
|
|
|
} from '../../lib/browser.ts'; |
|
|
|
|
|
|
|
|
|
|
|
type GoogleButtonProps = { |
|
|
|
type GoogleButtonProps = { |
|
|
|
isDisabled?: boolean; |
|
|
|
isDisabled?: boolean; |
|
|
@ -37,6 +41,8 @@ export function GoogleButton(props: GoogleButtonProps) { |
|
|
|
}`,
|
|
|
|
}`,
|
|
|
|
) |
|
|
|
) |
|
|
|
.then(({ response, error }) => { |
|
|
|
.then(({ response, error }) => { |
|
|
|
|
|
|
|
const utmParams = getStoredUtmParams(); |
|
|
|
|
|
|
|
|
|
|
|
if (!response?.token) { |
|
|
|
if (!response?.token) { |
|
|
|
setError(error?.message || 'Something went wrong.'); |
|
|
|
setError(error?.message || 'Something went wrong.'); |
|
|
|
setIsLoading(false); |
|
|
|
setIsLoading(false); |
|
|
@ -45,6 +51,8 @@ export function GoogleButton(props: GoogleButtonProps) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
triggerUtmRegistration(); |
|
|
|
|
|
|
|
|
|
|
|
let redirectUrl = '/'; |
|
|
|
let redirectUrl = '/'; |
|
|
|
const googleRedirectAt = localStorage.getItem(GOOGLE_REDIRECT_AT); |
|
|
|
const googleRedirectAt = localStorage.getItem(GOOGLE_REDIRECT_AT); |
|
|
|
const lastPageBeforeGoogle = localStorage.getItem(GOOGLE_LAST_PAGE); |
|
|
|
const lastPageBeforeGoogle = localStorage.getItem(GOOGLE_LAST_PAGE); |
|
|
@ -97,9 +105,12 @@ export function GoogleButton(props: GoogleButtonProps) { |
|
|
|
// For non authentication pages, we want to redirect back to the page
|
|
|
|
// For non authentication pages, we want to redirect back to the page
|
|
|
|
// the user was on before they clicked the social login button
|
|
|
|
// the user was on before they clicked the social login button
|
|
|
|
if (!['/login', '/signup'].includes(window.location.pathname)) { |
|
|
|
if (!['/login', '/signup'].includes(window.location.pathname)) { |
|
|
|
const pagePath = ['/respond-invite', '/befriend', '/r', '/ai'].includes( |
|
|
|
const pagePath = [ |
|
|
|
window.location.pathname, |
|
|
|
'/respond-invite', |
|
|
|
) |
|
|
|
'/befriend', |
|
|
|
|
|
|
|
'/r', |
|
|
|
|
|
|
|
'/ai', |
|
|
|
|
|
|
|
].includes(window.location.pathname) |
|
|
|
? window.location.pathname + window.location.search |
|
|
|
? window.location.pathname + window.location.search |
|
|
|
: window.location.pathname; |
|
|
|
: window.location.pathname; |
|
|
|
|
|
|
|
|
|
|
|