From 872be9ead16eb626fef32576c1e48e15a975b4bf Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 18 Feb 2024 11:54:22 -0600 Subject: [PATCH] Flesh out AccountStep --- .../nostr-signin-modal/steps/account-step.tsx | 56 +++++++++++++++++-- .../steps/identity-step.tsx | 9 ++- src/schemas/account.ts | 1 + 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx index 1a01cc77d0..2527bd7791 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx @@ -1,7 +1,9 @@ -import React from 'react'; +import { NSchema as n } from 'nspec'; +import React, { useMemo } from 'react'; import { useAccountLookup } from 'soapbox/api/hooks'; -import Stack from 'soapbox/components/ui/stack/stack'; +import { Avatar, Text, Stack, Emoji, Button, Tooltip } from 'soapbox/components/ui'; +import { useInstance } from 'soapbox/hooks'; interface IAccountStep { username: string; @@ -9,10 +11,56 @@ interface IAccountStep { const AccountStep: React.FC = ({ username }) => { const { account } = useAccountLookup(username); + const instance = useInstance(); + + const isBech32 = useMemo( + () => n.bech32().safeParse(account?.acct).success, + [account?.acct], + ); + + if (!account) { + return null; + } return ( - - {JSON.stringify(account, null, 2)} + + + + + + + + + + {isBech32 ? ( + account.acct.slice(0, 13) + ) : ( + account.acct + )} + + + + + + {!account.ditto.is_registered && ( + + + + + + You need an account on {instance.title} to continue. + + + + + + )} ); }; diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx index c4a207250f..5d20c0b1cc 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx @@ -71,7 +71,14 @@ const IdentityStep: React.FC = ({ username, setUsername, setStep - + + diff --git a/src/schemas/account.ts b/src/schemas/account.ts index 40a5e55374..696ed13754 100644 --- a/src/schemas/account.ts +++ b/src/schemas/account.ts @@ -33,6 +33,7 @@ const baseAccountSchema = z.object({ display_name: z.string().catch(''), ditto: coerceObject({ accepts_zaps: z.boolean().catch(false), + is_registered: z.boolean().catch(false), }), emojis: filteredArray(customEmojiSchema), fields: filteredArray(fieldSchema),