import {useMemo, useState} from 'react' import {Modal, View} from 'react-native' import {SystemBars} from 'react-native-edge-to-edge' import {KeyboardAwareScrollView} from 'react-native-keyboard-controller' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {type ComAtprotoAdminDefs, ComAtprotoModerationDefs} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useMutation} from '@tanstack/react-query' import Graphemer from 'graphemer' import {MAX_REPORT_REASON_GRAPHEME_LENGTH} from '#/lib/constants' import {useEnableKeyboardController} from '#/lib/hooks/useEnableKeyboardController' import {cleanError} from '#/lib/strings/errors' import {isIOS, isWeb} from '#/platform/detection' import {useAgent, useSession, useSessionApi} from '#/state/session' import {CharProgress} from '#/view/com/composer/char-progress/CharProgress' import {Logo} from '#/view/icons/Logo' import {atoms as a, native, useBreakpoints, useTheme, web} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as TextField from '#/components/forms/TextField' import {InlineLinkText} from '#/components/Link' import {Loader} from '#/components/Loader' import {P, Text} from '#/components/Typography' const COL_WIDTH = 400 export function Takendown() { const {_} = useLingui() const t = useTheme() const insets = useSafeAreaInsets() const {gtMobile} = useBreakpoints() const {currentAccount} = useSession() const {logoutCurrentAccount} = useSessionApi() const agent = useAgent() const [isAppealling, setIsAppealling] = useState(false) const [reason, setReason] = useState('') const graphemer = useMemo(() => new Graphemer(), []) const reasonGraphemeLength = useMemo(() => { return graphemer.countGraphemes(reason) }, [graphemer, reason]) const { mutate: submitAppeal, isPending, isSuccess, error, } = useMutation({ mutationFn: async (appealText: string) => { if (!currentAccount) throw new Error('No session') await agent.com.atproto.moderation.createReport({ reasonType: ComAtprotoModerationDefs.REASONAPPEAL, subject: { $type: 'com.atproto.admin.defs#repoRef', did: currentAccount.did, } satisfies ComAtprotoAdminDefs.RepoRef, reason: appealText, }) }, onSuccess: () => setReason(''), }) const primaryBtn = isAppealling && !isSuccess ? ( ) : ( ) const secondaryBtn = isAppealling ? ( !isSuccess && ( ) ) : ( ) const webLayout = isWeb && gtMobile useEnableKeyboardController(true) return ( {isIOS && } {isAppealling ? ( Appeal suspension ) : ( Your account has been suspended )} {isAppealling ? ( {isSuccess ? (

Your appeal has been submitted. If your appeal succeeds, you will receive an email.

) : ( <> Reason for appeal MAX_REPORT_REASON_GRAPHEME_LENGTH || !!error }> )} {error && ( {cleanError(error)} )}
) : (

Your account was found to be in violation of the{' '} Bluesky Social Terms of Service . You have been sent an email outlining the specific violation and suspension period, if applicable. You can appeal this decision if you believe it was made in error.

)} {webLayout && ( {secondaryBtn} {primaryBtn} )}
{!webLayout && ( {primaryBtn} {secondaryBtn} )}
) }