From bc2ddc620fcc001e562632695e8eb3a3dc2e9064 Mon Sep 17 00:00:00 2001 From: ameer2468 <33054370+ameer2468@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:16:55 +0300 Subject: [PATCH] improve auth ui --- .../client/AccountSettings/AccountLogin.tsx | 24 ++++------- .../client/AccountSettings/AccountProfile.tsx | 1 + .../settings/client/AccountSettings/Login.tsx | 22 ++++++---- .../client/AccountSettings/Register.tsx | 42 +++++++++++-------- .../client/AccountSettings/ShowPassword.tsx | 28 ++++++------- 5 files changed, 62 insertions(+), 55 deletions(-) diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/AccountLogin.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/AccountLogin.tsx index 19bfe2374..ec36ee3c9 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/AccountLogin.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/AccountLogin.tsx @@ -1,16 +1,12 @@ -import { useNavigation } from '@react-navigation/native'; import { MotiView } from 'moti'; import { AppleLogo, GithubLogo, GoogleLogo, IconProps } from 'phosphor-react-native'; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import { Text, View } from 'react-native'; import { LinearTransition } from 'react-native-reanimated'; -import { getAuthorisationURLWithQueryParamsAndSetState } from 'supertokens-web-js/recipe/thirdparty'; import Card from '~/components/layout/Card'; import ScreenContainer from '~/components/layout/ScreenContainer'; import { Button } from '~/components/primitive/Button'; -import { toast } from '~/components/primitive/Toast'; import { tw, twStyle } from '~/lib/tailwind'; -import { SettingsStackScreenProps } from '~/navigation/tabs/SettingsStack'; import Login from './Login'; import Register from './Register'; @@ -106,7 +102,7 @@ const AccountLogin = () => { - + {AccountTabs.map((text) => ( ))} - + {activeTab === 'Login' ? : } {/* Disabled for now */} - {/* + {/* OR @@ -154,7 +148,7 @@ const AccountLogin = () => { variant="outline" onPress={async () => await socialLoginHandlers(social.name)} key={social.name} - style={tw`rounded-full border border-app-line bg-app-input p-3`} + style={tw`p-3 border rounded-full border-app-line bg-app-input`} > diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/AccountProfile.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/AccountProfile.tsx index 9f670227b..3bf33edab 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/AccountProfile.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/AccountProfile.tsx @@ -30,6 +30,7 @@ const AccountProfile = () => { const emailName = userInfo ? userInfo.email.split('@')[0] : ''; const capitalizedEmailName = (emailName?.charAt(0).toUpperCase() ?? '') + emailName?.slice(1); const navigator = useNavigation['navigation']>(); + function signOut() { fetch(`${AUTH_SERVER_URL}/api/auth/signout`, { method: 'POST' diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx index 91f9d931f..3f9829cd9 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx @@ -8,7 +8,7 @@ import { useZodForm } from '@sd/client'; import { Button } from '~/components/primitive/Button'; import { Input } from '~/components/primitive/Input'; import { toast } from '~/components/primitive/Toast'; -import { tw } from '~/lib/tailwind'; +import { tw, twStyle } from '~/lib/tailwind'; import { SettingsStackScreenProps } from '~/navigation/tabs/SettingsStack'; import { AUTH_SERVER_URL } from '~/utils'; @@ -109,15 +109,18 @@ const Login = () => { control={form.control} name="email" render={({ field }) => ( - + {form.formState.errors.email && ( - + {form.formState.errors.email.message} )} @@ -128,16 +131,19 @@ const Login = () => { control={form.control} name="password" render={({ field }) => ( - + {form.formState.errors.password && ( - + {form.formState.errors.password.message} )} @@ -156,7 +162,7 @@ const Login = () => { })} disabled={form.formState.isSubmitting} > - Submit + Submit diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/Register.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/Register.tsx index e7a86a3b7..baf77d784 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/Register.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/Register.tsx @@ -3,13 +3,11 @@ import { useNavigation } from '@react-navigation/native'; import { useState } from 'react'; import { Controller, useForm } from 'react-hook-form'; import { Text, View } from 'react-native'; -import { signUp } from 'supertokens-web-js/recipe/emailpassword'; import { z } from 'zod'; -import { telemetryState } from '@sd/client'; import { Button } from '~/components/primitive/Button'; import { Input } from '~/components/primitive/Input'; import { toast } from '~/components/primitive/Toast'; -import { tw } from '~/lib/tailwind'; +import { tw, twStyle } from '~/lib/tailwind'; import { SettingsStackScreenProps } from '~/navigation/tabs/SettingsStack'; import { AUTH_SERVER_URL } from '~/utils'; @@ -108,7 +106,12 @@ const Register = () => { control={form.control} name="email" render={({ field }) => ( - + )} /> {form.formState.errors.email && ( @@ -122,7 +125,10 @@ const Register = () => { @@ -138,14 +144,22 @@ const Register = () => { control={form.control} name="confirmPassword" render={({ field }) => ( - + + {form.formState.errors.confirmPassword && ( + + {form.formState.errors.confirmPassword.message} + + )} { )} /> - {form.formState.errors.confirmPassword && ( - - {form.formState.errors.confirmPassword.message} - - )} ); diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/ShowPassword.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/ShowPassword.tsx index 5da608d46..ea33539dd 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/ShowPassword.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/ShowPassword.tsx @@ -1,5 +1,5 @@ import { Eye, EyeClosed } from 'phosphor-react-native'; -import { Text, View } from 'react-native'; +import { Text } from 'react-native'; import { Button } from '~/components/primitive/Button'; import { tw } from '~/lib/tailwind'; @@ -11,20 +11,18 @@ interface Props { const ShowPassword = ({ showPassword, setShowPassword, plural }: Props) => { return ( - - - + ); };