diff --git a/src/components/AuthenticationFlow/GoogleButton.tsx b/src/components/AuthenticationFlow/GoogleButton.tsx index e7e222a4b..9841530a7 100644 --- a/src/components/AuthenticationFlow/GoogleButton.tsx +++ b/src/components/AuthenticationFlow/GoogleButton.tsx @@ -1,9 +1,9 @@ import { useEffect, useState } from 'react'; import Cookies from 'js-cookie'; -import GoogleIcon from '../../icons/google.svg'; -import SpinnerIcon from '../../icons/spinner.svg'; import { TOKEN_COOKIE_NAME } from '../../lib/jwt'; import { httpGet } from '../../lib/http'; +import { Spinner } from '../ReactIcons/Spinner.tsx'; +import { GoogleIcon } from '../ReactIcons/GoogleIcon.tsx'; type GoogleButtonProps = {}; @@ -13,7 +13,6 @@ const GOOGLE_LAST_PAGE = 'googleLastPage'; export function GoogleButton(props: GoogleButtonProps) { const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(''); - const icon = isLoading ? SpinnerIcon : GoogleIcon; useEffect(() => { const urlParams = new URLSearchParams(window.location.search); @@ -29,7 +28,7 @@ export function GoogleButton(props: GoogleButtonProps) { httpGet<{ token: string }>( `${import.meta.env.PUBLIC_API_URL}/v1-google-callback${ window.location.search - }` + }`, ) .then(({ response, error }) => { if (!response?.token) { @@ -79,7 +78,7 @@ export function GoogleButton(props: GoogleButtonProps) { const handleClick = () => { setIsLoading(true); httpGet<{ loginUrl: string }>( - `${import.meta.env.PUBLIC_API_URL}/v1-google-login` + `${import.meta.env.PUBLIC_API_URL}/v1-google-login`, ) .then(({ response, error }) => { if (!response?.loginUrl) { @@ -93,7 +92,7 @@ export function GoogleButton(props: GoogleButtonProps) { // the user was on before they clicked the social login button if (!['/login', '/signup'].includes(window.location.pathname)) { const pagePath = ['/respond-invite', '/befriend'].includes( - window.location.pathname + window.location.pathname, ) ? window.location.pathname + window.location.search : window.location.pathname; @@ -117,11 +116,11 @@ export function GoogleButton(props: GoogleButtonProps) { disabled={isLoading} onClick={handleClick} > - Google + {isLoading ? ( + + ) : ( + + )} Continue with Google {error && ( diff --git a/src/components/AuthenticationFlow/LinkedInButton.tsx b/src/components/AuthenticationFlow/LinkedInButton.tsx index eb93b4517..e45483bd8 100644 --- a/src/components/AuthenticationFlow/LinkedInButton.tsx +++ b/src/components/AuthenticationFlow/LinkedInButton.tsx @@ -1,9 +1,9 @@ import { useEffect, useState } from 'react'; import Cookies from 'js-cookie'; -import LinkedIn from '../../icons/linkedin.svg'; -import SpinnerIcon from '../../icons/spinner.svg'; import { TOKEN_COOKIE_NAME } from '../../lib/jwt'; import { httpGet } from '../../lib/http'; +import { Spinner } from '../ReactIcons/Spinner.tsx'; +import { LinkedInIcon } from '../ReactIcons/LinkedInIcon.tsx'; type LinkedInButtonProps = {}; @@ -13,7 +13,6 @@ const LINKEDIN_LAST_PAGE = 'linkedInLastPage'; export function LinkedInButton(props: LinkedInButtonProps) { const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(''); - const icon = isLoading ? SpinnerIcon : LinkedIn; useEffect(() => { const urlParams = new URLSearchParams(window.location.search); @@ -29,7 +28,7 @@ export function LinkedInButton(props: LinkedInButtonProps) { httpGet<{ token: string }>( `${import.meta.env.PUBLIC_API_URL}/v1-linkedin-callback${ window.location.search - }` + }`, ) .then(({ response, error }) => { if (!response?.token) { @@ -79,7 +78,7 @@ export function LinkedInButton(props: LinkedInButtonProps) { const handleClick = () => { setIsLoading(true); httpGet<{ loginUrl: string }>( - `${import.meta.env.PUBLIC_API_URL}/v1-linkedin-login` + `${import.meta.env.PUBLIC_API_URL}/v1-linkedin-login`, ) .then(({ response, error }) => { if (!response?.loginUrl) { @@ -93,7 +92,7 @@ export function LinkedInButton(props: LinkedInButtonProps) { // the user was on before they clicked the social login button if (!['/login', '/signup'].includes(window.location.pathname)) { const pagePath = ['/respond-invite', '/befriend'].includes( - window.location.pathname + window.location.pathname, ) ? window.location.pathname + window.location.search : window.location.pathname; @@ -117,11 +116,11 @@ export function LinkedInButton(props: LinkedInButtonProps) { disabled={isLoading} onClick={handleClick} > - Google + {isLoading ? ( + + ) : ( + + )} Continue with LinkedIn {error && ( diff --git a/src/components/ReactIcons/GoogleIcon.tsx b/src/components/ReactIcons/GoogleIcon.tsx new file mode 100644 index 000000000..5da3082e1 --- /dev/null +++ b/src/components/ReactIcons/GoogleIcon.tsx @@ -0,0 +1,32 @@ +type GoogleIconProps = { + className?: string; +}; +export function GoogleIcon(props: GoogleIconProps) { + const { className } = props; + + return ( + + + + + + + ); +} diff --git a/src/components/ReactIcons/LinkedInIcon.tsx b/src/components/ReactIcons/LinkedInIcon.tsx new file mode 100644 index 000000000..0c276044d --- /dev/null +++ b/src/components/ReactIcons/LinkedInIcon.tsx @@ -0,0 +1,49 @@ +type LinkedInIconProps = { + className?: string; +}; + +export function LinkedInIcon(props: LinkedInIconProps) { + const { className } = props; + + return ( + + + + + + + + + + + ); +}