about summary refs log tree commit diff
path: root/src/components/verification
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2025-04-24 11:46:23 -0500
committerGitHub <noreply@github.com>2025-04-24 11:46:23 -0500
commit6f44abee35437e4cd51b3f60819f1b6017e6df34 (patch)
treefa58dd1ecd6c2bdcc75aa030a69346e2460e6089 /src/components/verification
parente1e936068a2f8e785135ad14143bae2335b7b387 (diff)
downloadvoidsky-6f44abee35437e4cd51b3f60819f1b6017e6df34.tar.zst
Verification UI tweaks (#8276)
* Prevent issuing verifications for users without display names

* Wait for success before closing, show errors

* Update icons

* WIP adjust size

* Adjust check size in feeds

* Add back unused icon

* Format
Diffstat (limited to 'src/components/verification')
-rw-r--r--src/components/verification/VerificationCreatePrompt.tsx80
1 files changed, 57 insertions, 23 deletions
diff --git a/src/components/verification/VerificationCreatePrompt.tsx b/src/components/verification/VerificationCreatePrompt.tsx
index 39ac6dbf6..eb57d7c36 100644
--- a/src/components/verification/VerificationCreatePrompt.tsx
+++ b/src/components/verification/VerificationCreatePrompt.tsx
@@ -1,15 +1,19 @@
-import {useCallback} from 'react'
+import {useCallback, useState} from 'react'
 import {View} from 'react-native'
-import {msg} from '@lingui/macro'
+import {msg, Trans} from '@lingui/macro'
 import {useLingui} from '@lingui/react'
 
 import {logger} from '#/logger'
 import {useModerationOpts} from '#/state/preferences/moderation-opts'
 import {useVerificationCreateMutation} from '#/state/queries/verification/useVerificationCreateMutation'
 import * as Toast from '#/view/com/util/Toast'
-import {atoms as a} from '#/alf'
+import {atoms as a, useBreakpoints} from '#/alf'
+import {Admonition} from '#/components/Admonition'
+import {Button, ButtonIcon, ButtonText} from '#/components/Button'
 import {type DialogControlProps} from '#/components/Dialog'
+import * as Dialog from '#/components/Dialog'
 import {VerifiedCheck} from '#/components/icons/VerifiedCheck'
+import {Loader} from '#/components/Loader'
 import * as ProfileCard from '#/components/ProfileCard'
 import * as Prompt from '#/components/Prompt'
 import type * as bsky from '#/types/bsky'
@@ -22,19 +26,22 @@ export function VerificationCreatePrompt({
   profile: bsky.profile.AnyProfileView
 }) {
   const {_} = useLingui()
+  const {gtMobile} = useBreakpoints()
   const moderationOpts = useModerationOpts()
-  const {mutateAsync: create} = useVerificationCreateMutation()
+  const {mutateAsync: create, isPending} = useVerificationCreateMutation()
+  const [error, setError] = useState(``)
   const onConfirm = useCallback(async () => {
     try {
       await create({profile})
       Toast.show(_(msg`Successfully verified`))
+      control.close()
     } catch (e) {
-      Toast.show(_(msg`Failed to create a verification`), 'xmark')
+      setError(_(msg`Verification failed, please try again.`))
       logger.error('Failed to create a verification', {
         safeMessage: e,
       })
     }
-  }, [_, profile, create])
+  }, [_, profile, create, control])
 
   return (
     <Prompt.Outer control={control}>
@@ -47,24 +54,51 @@ export function VerificationCreatePrompt({
       <Prompt.DescriptionText>
         {_(msg`This action can be undone at any time.`)}
       </Prompt.DescriptionText>
-      <View style={[a.pb_xl]}>
-        {moderationOpts ? (
-          <ProfileCard.Header>
-            <ProfileCard.Avatar
-              profile={profile}
-              moderationOpts={moderationOpts}
-            />
-            <ProfileCard.NameAndHandle
-              profile={profile}
-              moderationOpts={moderationOpts}
-            />
-          </ProfileCard.Header>
-        ) : null}
+
+      {moderationOpts ? (
+        <ProfileCard.Header>
+          <ProfileCard.Avatar
+            profile={profile}
+            moderationOpts={moderationOpts}
+          />
+          <ProfileCard.NameAndHandle
+            profile={profile}
+            moderationOpts={moderationOpts}
+          />
+        </ProfileCard.Header>
+      ) : null}
+
+      {error && (
+        <View style={[a.pt_lg]}>
+          <Admonition type="error">{error}</Admonition>
+        </View>
+      )}
+
+      <View style={[a.pt_xl]}>
+        {profile.displayName ? (
+          <Prompt.Actions>
+            <Button
+              variant="solid"
+              color="primary"
+              size={gtMobile ? 'small' : 'large'}
+              label={_(msg`Verify account`)}
+              onPress={onConfirm}>
+              <ButtonText>{_(msg`Verify account`)}</ButtonText>
+              {isPending && <ButtonIcon icon={Loader} />}
+            </Button>
+            <Prompt.Cancel />
+          </Prompt.Actions>
+        ) : (
+          <Admonition type="warning">
+            <Trans>
+              This user does not have a display name, and therefore cannot be
+              verified.
+            </Trans>
+          </Admonition>
+        )}
       </View>
-      <Prompt.Actions>
-        <Prompt.Action cta={_(msg`Verify account`)} onPress={onConfirm} />
-        <Prompt.Cancel />
-      </Prompt.Actions>
+
+      <Dialog.Close />
     </Prompt.Outer>
   )
 }