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.
This commit is contained in:
adilallo committed 2026-11-09 19:54:09 -07:00
1 parent 5cbda35e32
commit b6795c1f18
28 files changed
+1467 -377

No files matched your search

+73 -1
View File
@@ -16,7 +16,18 @@ import {
logout,
requestEmailChange,
type MyPublishedRule,
type PublishedRuleDetailForClient,
} from "../../../lib/create/api";
import {
downloadStoredRuleAsPdf,
downloadTextFile,
exportFilenameBase,
exportStoredRuleAsMarkdown,
} from "../../../lib/create/ruleExport";
import {
writeLastPublishedRule,
type StoredLastPublishedRule,
} from "../../../lib/create/lastPublishedRule";
import {
CREATE_FLOW_MANAGE_STAKEHOLDERS_QUERY,
CREATE_FLOW_MANAGE_STAKEHOLDERS_VALUE,
@@ -29,7 +40,6 @@ import { clearAnonymousCreateFlowStorage } from "../create/utils/anonymousDraftS
import { clearCoreValueDetailsLocalStorage } from "../create/utils/coreValueDetailsLocalStorage";
import { prepareFreshCreateFlowEntrySync } from "../create/utils/prepareFreshCreateFlowEntry";
import { createFlowStepPath } from "../create/utils/createFlowPaths";
import { writeLastPublishedRule } from "../../../lib/create/lastPublishedRule";
import { useMediaQuery } from "../../hooks/useMediaQuery";
import {
ProfilePageSignedOutView,
@@ -315,6 +325,66 @@ export default function ProfilePageClient() {
void load();
}, [draftDeleteBusy, load]);
const toStoredRule = useCallback(
(rule: PublishedRuleDetailForClient): StoredLastPublishedRule | null => {
if (
rule.document === null ||
typeof rule.document !== "object" ||
Array.isArray(rule.document)
) {
return null;
}
return {
id: rule.id,
title: rule.title,
summary: rule.summary,
document: rule.document as Record<string, unknown>,
};
},
[],
);
const handleExportRulePdf = useCallback(
async (id: string) => {
setActionError(null);
const detail = await fetchPublishedRuleDetail(id);
const stored = detail ? toStoredRule(detail.rule) : null;
if (!stored) {
setActionError(t("actionError"));
return;
}
try {
downloadStoredRuleAsPdf(stored);
} catch {
setActionError(t("actionError"));
}
},
[t, toStoredRule],
);
const handleExportRuleMarkdown = useCallback(
async (id: string) => {
setActionError(null);
const detail = await fetchPublishedRuleDetail(id);
const stored = detail ? toStoredRule(detail.rule) : null;
if (!stored) {
setActionError(t("actionError"));
return;
}
try {
const markdown = exportStoredRuleAsMarkdown(stored);
downloadTextFile(
`${exportFilenameBase(stored)}-community-rule.md`,
markdown,
"text/markdown;charset=utf-8",
);
} catch {
setActionError(t("actionError"));
}
},
[t, toStoredRule],
);
const handleConfirmDeleteAccount = useCallback(async () => {
setActionError(null);
setAccountDeleteBusy(true);
@@ -409,6 +479,8 @@ export default function ProfilePageClient() {
}}
onCloseDeleteAccount={() => setAccountDeleteOpen(false)}
onConfirmDeleteAccount={handleConfirmDeleteAccount}
onExportRulePdf={(id) => void handleExportRulePdf(id)}
onExportRuleMarkdown={(id) => void handleExportRuleMarkdown(id)}
onStartNewCustomRule={handleStartNewCustomRule}
/>
);