Mobilens 中文

Flow · Account

Delete account

Every screen in this flow

Review

Confirm

Done

When
Way out
Next
Behaviour

    Usage

    import { DeleteAccount, type DeleteResult } from '@/components/mobilens/DeleteAccount';
    
    async function deleteAccount(): Promise<DeleteResult> {
      const res = await fetch('https://api.example.com/me', { method: 'DELETE' });
      if (res.ok) return { status: 'deleted' };
      if (res.status === 409) return { status: 'rejected', reason: 'You have an active subscription. Cancel it first.', fixLabel: 'Manage subscription' };
      return { status: 'failed' };
    }
    
    export function DeleteAccountScreen({ signOut, openSubscriptions }: { signOut: () => void; openSubscriptions: () => void }) {
      return (
        <DeleteAccount
          deleteAccount={deleteAccount}
          onDeleted={signOut}
          onFix={openSubscriptions}
          losing={['Your profile and username', 'Your photos and albums', 'Your messages']}
        />
      );
    }
    

    API

    PropTypeDefaultDescription
    title? string 'Delete account' Heading shown on the account review step.
    primaryLabel? string 'Delete account' Label of the review button that opens the confirmation sheet.
    labels? Partial<DeleteAccountLabels> – The words the screen shows. Pass a partial set to change only some of them.
    deleteAccount () => Promise<DeleteResult> – Deletes the account. A call that throws counts as failed.
    onDeleted () => void – Called after the goodbye screen's button: sign out and go to the start.
    onFix? () => void – Called when the user taps the fix for a rejection, such as Manage subscription.
    losing string[] – What is deleted, one line each.
    confirmWord? string 'DELETE' The word to type to confirm.
    autoFocus? boolean true Focus the field and bring up the keyboard when the sheet opens.
    initialStep? DeleteStep 'review' Where to start. Defaults to the review; pass a step in tests.
    onStepChange? (step: DeleteStep) => void – Called with every step the screen enters, for analytics or logging.

    Controls in this flow