From 2ada6b39e21e105257485f24d0e64da621c13be4 Mon Sep 17 00:00:00 2001 From: Jakz Date: Wed, 6 Sep 2023 12:25:08 +0800 Subject: [PATCH] [GAL-4095] [GAL-4114] Enable Sign Up with Wallet (#1855) * Make button text optional * Add dependency * Add connect wallet button * Disconnect wallet when logout * eth icon support sizing * Add wallet selection * Add sign in bottom sheet * Bottom sheet row support icon * Move createNonce to shared * removed unused file * lint shared * prettier * add try catch block * set loading false * Add dark mode + icons * fix loading state * turn off onboarding flag * rename heading * Add loading signature state * Update metadata * consolidate email icon * update border on dark mode * update spinner on dark mode * reset state on dismiss * handle reject signature * Add username screen * Add profile bio onboarding screen * move util to shared * Update shared path on web * Add check username logic * move update update user hooks to shared * Move bio count to shared * navigate to bio screen * able to set pfp n add sync * Fix typecheck path * Add welcome bottom sheet * Remove toast * Add curated direction props * show welcome bottom for new user * lint * fix fetch user profile after signed up * fix shifted button * standardize error state * Add event tracker * remove console * Rename the copywriting * Added comment to remove manual sync * If created user, able to update username * fix typo --- .../components/Login/ConnectWalletButton.tsx | 28 +- apps/mobile/src/components/WelcomeNewUser.tsx | 53 ++++ .../src/navigation/LoginStackNavigator.tsx | 7 + apps/mobile/src/navigation/types.ts | 24 +- .../src/screens/HomeScreen/CuratedScreen.tsx | 32 +-- ...avigateToNotificationUpsellOrHomeScreen.ts | 11 +- .../Onboarding/OnboardingProfileBioScreen.tsx | 168 +++++++++++ .../Onboarding/OnboardingUsernameScreen.tsx | 261 ++++++++++++++++++ .../screens/ProfileScreen/ProfileScreen.tsx | 2 +- .../Announcement/AnnouncementList.tsx | 2 +- apps/web/src/components/Email/EmailForm.tsx | 2 +- .../components/Follow/FollowListUserItem.tsx | 2 +- .../src/components/Profile/UserInfoForm.tsx | 3 +- .../src/components/Profile/useUserInfoForm.ts | 39 +-- .../TokenHolderListGalleryPreview.tsx | 2 +- .../multichain/MagicLinkLogin.tsx | 2 +- apps/web/src/utils/formatUrl.ts | 2 +- apps/web/src/utils/regex.test.tsx | 2 +- apps/web/src/utils/token.ts | 2 +- .../shared/src/hooks/useAuthPayloadQuery.ts | 21 ++ .../shared/src/hooks}/useCreateUser.ts | 2 +- .../shared/src/hooks}/useUpdateUser.ts | 5 +- ...useUserInfoFormIsUsernameAvailableQuery.ts | 32 +++ .../shared}/src/utils/regex.ts | 0 .../shared}/src/utils/validators.ts | 0 25 files changed, 626 insertions(+), 78 deletions(-) create mode 100644 apps/mobile/src/components/WelcomeNewUser.tsx create mode 100644 apps/mobile/src/screens/Onboarding/OnboardingProfileBioScreen.tsx create mode 100644 apps/mobile/src/screens/Onboarding/OnboardingUsernameScreen.tsx create mode 100644 packages/shared/src/hooks/useAuthPayloadQuery.ts rename {apps/web/src/hooks/api/users => packages/shared/src/hooks}/useCreateUser.ts (97%) rename {apps/web/src/hooks/api/users => packages/shared/src/hooks}/useUpdateUser.ts (94%) create mode 100644 packages/shared/src/hooks/useUserInfoFormIsUsernameAvailableQuery.ts rename {apps/web => packages/shared}/src/utils/regex.ts (100%) rename {apps/web => packages/shared}/src/utils/validators.ts (100%) diff --git a/apps/mobile/src/components/Login/ConnectWalletButton.tsx b/apps/mobile/src/components/Login/ConnectWalletButton.tsx index e4858f7f67..2515b71f1c 100644 --- a/apps/mobile/src/components/Login/ConnectWalletButton.tsx +++ b/apps/mobile/src/components/Login/ConnectWalletButton.tsx @@ -54,21 +54,29 @@ export function ConnectWalletButton() { const signer = web3Provider.getSigner(); const { nonce, user_exists: userExist } = await createNonce(address, 'Ethereum'); - if (!userExist) { - pushToast({ - message: 'You need to sign up first', - withoutNavbar: true, - }); - setIsLoading(false); - provider?.disconnect(); - return; - } - try { setIsLoading(true); setIsSigningIn(true); const signature = await signer.signMessage(nonce); + if (!userExist) { + setIsLoading(false); + provider?.disconnect(); + + navigation.navigate('OnboardingUsername', { + authMechanism: { + authMechanismType: 'eoa', + chain: 'Ethereum', + address, + nonce, + signature, + userFriendlyWalletName: 'Unknown', + }, + }); + + return; + } + const result = await login({ eoa: { signature, diff --git a/apps/mobile/src/components/WelcomeNewUser.tsx b/apps/mobile/src/components/WelcomeNewUser.tsx new file mode 100644 index 0000000000..ff2ad51910 --- /dev/null +++ b/apps/mobile/src/components/WelcomeNewUser.tsx @@ -0,0 +1,53 @@ +import { useEffect, useMemo, useRef } from 'react'; +import { View } from 'react-native'; + +import { Button } from './Button'; +import { + GalleryBottomSheetModal, + GalleryBottomSheetModalType, +} from './GalleryBottomSheet/GalleryBottomSheetModal'; +import { Typography } from './Typography'; + +type Props = { + username: string; +}; + +export function WelcomeNewUser({ username }: Props) { + const snapPoints = useMemo(() => [360], []); + const bottomSheetRef = useRef(null); + useEffect(() => bottomSheetRef.current?.present(), []); + + return ( + + + + + + Welcome to your feed, + + + {username}! + + + + This is where you'll see what people are collecting, creating and sharing. Choose 'For + You' for tailored content or 'Following' to see what your connections are up to! + + + +