webapp/src/components/Nav/AuthModal/SocialProviders.tsx

37 lines
1.1 KiB
TypeScript
Raw Normal View History

import { useLocalize } from '../../../context/localize'
2024-01-19 15:03:33 +00:00
import { useSession } from '../../../context/session'
import { Icon } from '../../_shared/Icon'
2022-10-25 16:25:42 +00:00
import styles from './SocialProviders.module.scss'
2024-01-19 15:03:33 +00:00
type Provider = 'facebook' | 'google' | 'github' // 'vk' | 'telegram'
2022-10-25 16:25:42 +00:00
export const SocialProviders = () => {
2023-02-17 09:21:02 +00:00
const { t } = useLocalize()
2024-01-19 15:03:33 +00:00
const {
actions: { oauthLogin },
} = useSession()
const handleClick = async (event: MouseEvent | TouchEvent, provider: Provider): Promise<void> => {
event.preventDefault()
await oauthLogin(provider)
}
2022-10-25 16:25:42 +00:00
return (
2024-01-19 15:03:33 +00:00
<div className={styles.container}>
<div className={styles.text}>{t('or sign in with social networks')}</div>
<div className={styles.social}>
<a href="#" onClick={(ev) => handleClick(ev, 'google')}>
<Icon name={'google'} />
2022-10-25 16:25:42 +00:00
</a>
2024-01-19 15:03:33 +00:00
<a href="#" onClick={(ev) => handleClick(ev, 'facebook')}>
<Icon name={'facebook'} />
2022-10-25 16:25:42 +00:00
</a>
2024-01-19 15:03:33 +00:00
<a href="#" class={styles.githubAuth} onClick={(ev) => handleClick(ev, 'github')}>
2022-10-25 16:25:42 +00:00
<Icon name="github" />
</a>
</div>
</div>
)
}