-
-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathindex.tsx
More file actions
37 lines (30 loc) · 1.17 KB
/
index.tsx
File metadata and controls
37 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react';
import { useTranslation } from 'react-i18next';
import cn from 'classnames';
import { Button } from 'components';
import { goToUrl } from 'libs';
import { useGoogleAuthorizeMutation } from 'services/auth';
import { ReactComponent as GoogleIcon } from 'assets/icons/google.svg';
import styles from './styles.module.scss';
export const LoginByGoogle: React.FC<{ className?: string }> = ({ className }) => {
const { t } = useTranslation();
const [googleAuthorize, { isLoading }] = useGoogleAuthorizeMutation();
const signInClick = () => {
googleAuthorize()
.unwrap()
.then((data) => {
goToUrl(data.authorization_url);
})
.catch(console.log);
};
return (
<div className={cn(styles.signIn, className)}>
<Button onClick={signInClick} disabled={isLoading} loading={isLoading} variant="normal">
<span className={styles.loginButtonInner}>
<GoogleIcon />
<span className={styles.loginButtonLabel}>{t('common.login_google')}</span>
</span>
</Button>
</div>
);
};