From 5c91b8764ea18dade5aa3e8d0b425a8aa54f7ece Mon Sep 17 00:00:00 2001 From: Ksinia Date: Tue, 1 Feb 2022 01:21:40 +0300 Subject: [PATCH] Switch QR to backend rendering --- frontend/app/components/auth/auth.module.css | 9 ++++-- frontend/app/components/auth/auth.tsx | 32 +++++++++++++++---- .../app/components/auth/components/oauth.tsx | 27 ++++++---------- frontend/package.json | 2 -- 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/frontend/app/components/auth/auth.module.css b/frontend/app/components/auth/auth.module.css index 6c05d2ce..9120cfcd 100644 --- a/frontend/app/components/auth/auth.module.css +++ b/frontend/app/components/auth/auth.module.css @@ -196,7 +196,12 @@ line-height: 1.2; } -.qr { +.telegramQR { display: block; - margin: 0 auto 1.5rem auto; + margin: 0 auto 0 auto; + width: 75%; +} + +.telegram { + margin-bottom: 0; } diff --git a/frontend/app/components/auth/auth.tsx b/frontend/app/components/auth/auth.tsx index 91bdf5a3..f5f83e8b 100644 --- a/frontend/app/components/auth/auth.tsx +++ b/frontend/app/components/auth/auth.tsx @@ -3,7 +3,6 @@ import { h, Fragment } from 'preact'; import { useState } from 'preact/hooks'; import { useIntl } from 'react-intl'; import { useSelector, useDispatch } from 'react-redux'; -import QRCode from 'qrcode.react'; import { setTelegramParams, setUser } from 'store/user/actions'; import { Input } from 'components/input'; @@ -17,10 +16,17 @@ import { OAuth } from './components/oauth'; import { messages } from './auth.messsages'; import { useDropdown } from './auth.hooks'; import { getProviders, getTokenInvalidReason } from './auth.utils'; -import { emailSignin, verifyEmailSignin, anonymousSignin, verifyTelegramSignin } from './auth.api'; +import { + emailSignin, + verifyEmailSignin, + anonymousSignin, + verifyTelegramSignin, + getTelegramSigninParams, +} from './auth.api'; import { StoreState } from 'store'; import styles from './auth.module.css'; +import { BASE_URL, API_BASE } from '../../common/constants.config'; export function Auth() { const intl = useIntl(); @@ -99,6 +105,17 @@ export function Auth() { setLoading(false); } + async function handleTelegramClick() { + if (!telegramParams) { + const params = await getTelegramSigninParams(); + if (params === null) { + return; + } + dispatch(setTelegramParams(params)); + } + setView && setView('telegram'); + } + async function handleTelegramSubmit(evt: Event) { evt.preventDefault(); setLoading(true); @@ -179,7 +196,7 @@ export function Auth() { -

+

{intl.formatMessage(messages.telegramMessage1)}{' '} {window.screen.width >= 768 && ( - )}