import {useCallback, useState} from 'react' import {View} from 'react-native' 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, 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' export function VerificationCreatePrompt({ control, profile, }: { control: DialogControlProps profile: bsky.profile.AnyProfileView }) { const {_} = useLingui() const {gtMobile} = useBreakpoints() const moderationOpts = useModerationOpts() 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) { setError(_(msg`Verification failed, please try again.`)) logger.error('Failed to create a verification', { safeMessage: e, }) } }, [_, profile, create, control]) return ( {_(msg`Verify this account?`)} {_(msg`This action can be undone at any time.`)} {moderationOpts ? ( ) : null} {error && ( {error} )} {profile.displayName ? ( ) : ( This user does not have a display name, and therefore cannot be verified. )} ) }