import {useState} from 'react' import {View} from 'react-native' import {KeyboardAwareScrollView} from 'react-native-keyboard-controller' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {type ComAtprotoAdminDefs, ToolsOzoneReportDefs} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useMutation} from '@tanstack/react-query' import {countGraphemes} from 'unicode-segmenter/grapheme' import { BLUESKY_MOD_SERVICE_HEADERS, MAX_REPORT_REASON_GRAPHEME_LENGTH, } from '#/lib/constants' import {useEnableKeyboardController} from '#/lib/hooks/useEnableKeyboardController' import {cleanError} from '#/lib/strings/errors' 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, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as TextField from '#/components/forms/TextField' import {SimpleInlineLinkText} from '#/components/Link' import {Loader} from '#/components/Loader' import {P, Text} from '#/components/Typography' import {IS_WEB} from '#/env' 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 reasonGraphemeLength = countGraphemes(reason) const isOverMaxLength = reasonGraphemeLength > MAX_REPORT_REASON_GRAPHEME_LENGTH 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: ToolsOzoneReportDefs.REASONAPPEAL, subject: { $type: 'com.atproto.admin.defs#repoRef', did: currentAccount.did, } satisfies ComAtprotoAdminDefs.RepoRef, reason: appealText, }, { encoding: 'application/json', headers: BLUESKY_MOD_SERVICE_HEADERS, }, ) }, onSuccess: () => setReason(''), }) const primaryBtn = isAppealling && !isSuccess ? ( ) : ( ) const secondaryBtn = isAppealling ? ( !isSuccess && ( ) ) : ( ) const webLayout = IS_WEB && gtMobile useEnableKeyboardController(true) return ( {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} )}
) }