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

47 lines
1.4 KiB
TypeScript
Raw Normal View History

import { useLocalize } from '../../../context/localize'
2022-10-25 16:25:42 +00:00
import { hideModal } from '../../../stores/ui'
import { Icon } from '../../_shared/Icon'
2022-10-25 16:25:42 +00:00
import styles from './SocialProviders.module.scss'
type Provider = 'facebook' | 'google' | 'vk' | 'github'
// 3rd party provider auth handler
const handleSocialAuthLinkClick = (event: MouseEvent, provider: Provider): void => {
event.preventDefault()
2023-11-29 08:23:08 +00:00
const popup = window.open(
`https://auth.discours.io/oauth_login/${provider}`,
provider,
'width=740, height=420',
) // TODO: precalculate window size
2022-10-25 16:25:42 +00:00
popup?.focus()
hideModal()
}
export const SocialProviders = () => {
2023-02-17 09:21:02 +00:00
const { t } = useLocalize()
2022-10-25 16:25:42 +00:00
return (
<div class={styles.container}>
2023-10-16 09:54:14 +00:00
<div class={styles.text}>{t('or sign in with social networks')}</div>
2022-10-25 16:25:42 +00:00
<div class={styles.social}>
<a href="#" onClick={(event) => handleSocialAuthLinkClick(event, 'facebook')}>
<Icon name="facebook" />
</a>
<a href="#" onClick={(event) => handleSocialAuthLinkClick(event, 'google')}>
<Icon name="google" />
</a>
<a href="#" onClick={(event) => handleSocialAuthLinkClick(event, 'vk')}>
<Icon name="vk" />
</a>
<a
href="#"
class={styles.githubAuth}
onClick={(event) => handleSocialAuthLinkClick(event, 'github')}
>
<Icon name="github" />
</a>
</div>
</div>
)
}