Files
community-rule/app/components/modals/DeleteAccount/DeleteAccount.view.tsx
T
adilallo b6795c1f18 Rebuild Share and Delete Account from the privacy designs.
Share asks the person who holds the pen to confirm their community agreed before a link turns on, and deleting an account lists each owned Rule with PDF and RULE.md export. Case-study Share copies the page link instead of opening the privacy modal, and the sign-in banner stays below the header so Share remains clickable.
2026-11-09 19:54:09 -07:00

140 lines
4.2 KiB
TypeScript

"use client";
import { memo } from "react";
import Avatar from "../../asset/Avatar";
import Icon from "../../asset/icon";
import Button from "../../buttons/Button";
import Checkbox from "../../controls/Checkbox";
import { CreateModalFrameView } from "../Create/CreateModalFrame.view";
import ModalHeader from "../ModalHeader";
import ContentLockup from "../../type/ContentLockup";
import { communityInviteInitials } from "../../../../lib/create/ruleInviteCardMeta";
import type { DeleteAccountViewProps } from "./DeleteAccount.types";
export const DeleteAccountView = memo(function DeleteAccountView({
isOpen,
onClose,
onConfirm,
busy,
rules,
onExportPdf,
onExportMarkdown,
className,
backdropVariant,
dialogRef,
overlayRef,
titleId,
copy,
understood,
onUnderstoodChange,
}: DeleteAccountViewProps) {
return (
<CreateModalFrameView
isOpen={isOpen}
onOverlayClick={busy ? () => undefined : onClose}
backdropVariant={backdropVariant}
presentation="sheet"
className={className}
ariaLabel={copy.title}
ariaLabelledBy={titleId}
overlayRef={overlayRef}
dialogRef={dialogRef}
>
<ModalHeader
onClose={busy ? undefined : onClose}
showMoreOptionsButton={false}
closeButtonAriaLabel={copy.closeDialogAriaLabel}
/>
<div className="shrink-0 bg-[var(--color-surface-default-primary)] px-6">
<ContentLockup
title={copy.title}
description={copy.description}
variant="modal"
alignment="left"
titleId={titleId}
/>
</div>
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-x-clip overflow-y-auto px-6 pb-6 pt-6">
<p className="w-full text-small-label text-[var(--color-content-default-secondary)]">
{copy.yourRules}
</p>
{rules.map((rule) => (
<div
key={rule.id}
className="flex w-full items-center gap-3 overflow-hidden rounded-[12px] bg-[var(--color-surface-default-secondary)] p-3"
>
<Avatar
alt=""
initials={communityInviteInitials(rule.title)}
size="large"
shape="circle"
variant="filled"
/>
<p className="min-w-0 flex-1 truncate text-small-label text-[var(--color-content-default-primary)]">
{rule.title}
</p>
<div className="flex shrink-0 items-start gap-2">
<Button
type="button"
buttonType="outline"
palette="default"
size="small"
disabled={busy}
onClick={() => onExportPdf(rule.id)}
>
<Icon name="picture_as_pdf" size={14} />
{copy.exportPdf}
</Button>
<Button
type="button"
buttonType="outline"
palette="default"
size="small"
disabled={busy}
onClick={() => onExportMarkdown(rule.id)}
>
<Icon name="markdown_copy" size={14} />
{copy.exportMarkdown}
</Button>
</div>
</div>
))}
<Checkbox
checked={understood}
disabled={busy}
label={copy.confirmLabel}
onChange={(data) => onUnderstoodChange(data.checked)}
/>
</div>
<div className="flex shrink-0 items-center justify-end gap-2 border-t border-solid border-[var(--color-border-default-secondary)] bg-[var(--color-surface-default-primary)] px-6 py-4">
<Button
type="button"
buttonType="outline"
palette="default"
size="small"
disabled={busy}
onClick={onClose}
>
{copy.cancel}
</Button>
<Button
type="button"
buttonType="outline"
palette="default"
size="small"
danger
disabled={busy || !understood}
onClick={onConfirm}
>
{copy.confirm}
</Button>
</div>
</CreateModalFrameView>
);
});
DeleteAccountView.displayName = "DeleteAccountView";