From ebc6f42df4c7be237ebe0289657d3d2b1c8002bf Mon Sep 17 00:00:00 2001 From: M Gilang Januar Date: Mon, 27 Dec 2021 13:43:19 +0700 Subject: [PATCH 1/2] add resend code and change phone number in login form --- web/src/pages/Login.tsx | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/web/src/pages/Login.tsx b/web/src/pages/Login.tsx index f4f160abc..534168b48 100644 --- a/web/src/pages/Login.tsx +++ b/web/src/pages/Login.tsx @@ -24,7 +24,7 @@ const Login: React.FC = () => { const [phoneCodeHash, setPhoneCodeHash] = useState() const [needPassword, setNeedPassword] = useState() const { data: me } = useSWRImmutable('/users/me', fetcher) - const { data: _ } = useSWRImmutable('/utils/ipinfo', fetcher, { onSuccess: ({ ipinfo }) => setPhoneData({ short: ipinfo?.country || 'ID' }) }) + const { data: _ } = useSWRImmutable('/utils/ipinfo', fetcher, { onSuccess: ({ ipinfo }) => setPhoneData(phoneData?.short ? phoneData : { short: ipinfo?.country || 'ID' }) }) const sendCode = async (phoneNumber?: string) => { phoneNumber = phoneNumber || phoneData.phone ? `+${phoneData.code}${phoneData.phone}` : '' @@ -38,7 +38,7 @@ const Login: React.FC = () => { const fetch = async (phoneCodeHash?: string) => { const { data } = phoneCodeHash ? await req.post('/auth/reSendCode', { phoneNumber, phoneCodeHash }) : await req.post('/auth/sendCode', { phoneNumber }) setPhoneCodeHash(data.phoneCodeHash) - setCountdown(60) + setCountdown(90) notification.info({ message: 'Sent!', description: 'Please check your Telegram app and input the code' @@ -48,7 +48,7 @@ const Login: React.FC = () => { try { setLoadingSendCode(true) await fetch(phoneCodeHash) - setCurrentStep(currentStep + 1) + setCurrentStep(1) } catch (error: any) { setLoadingSendCode(false) notification.error({ @@ -141,23 +141,30 @@ const Login: React.FC = () => { {/* */} - + } {currentStep === 1 && <> - + - {/* */} + {countdown ? Re-send in {countdown}s... : + + } - - + + + + + + + } @@ -165,8 +172,8 @@ const Login: React.FC = () => { - - + + } From 77d286ba39971d55fbb66fcaeda3d1210422c100 Mon Sep 17 00:00:00 2001 From: M Gilang Januar Date: Mon, 27 Dec 2021 13:44:53 +0700 Subject: [PATCH 2/2] 1.1.1 --- package.json | 2 +- server/package.json | 2 +- web/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b7693c50d..ba8d70c5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "teledrive", - "version": "1.1.0", + "version": "1.1.1", "repository": "git@github.com:mgilangjanuar/teledrive.git", "author": "M Gilang Januar ", "license": "MIT", diff --git a/server/package.json b/server/package.json index 9b44ce9db..6091a51e9 100644 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "server", - "version": "1.1.0", + "version": "1.1.1", "main": "dist/index.js", "license": "MIT", "private": true, diff --git a/web/package.json b/web/package.json index 7fa2e18ee..99a43f054 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.1.0", + "version": "1.1.1", "private": true, "dependencies": { "@craco/craco": "^6.3.0",