export const DISABLE_REASONS = ["payment_dispute", "admin"] as const;
export type DisableReason = (typeof DISABLE_REASONS)[number];
export type DisabledNotice = { reason: string; message: string; supportEmail: string | null };
/** The text every refusal and notice shows; the support address is the only way back in. */
export function disabledMessage(reason: string, supportEmail: string | null): string {
const contact = supportEmail ? `Email ${supportEmail} to resolve it.` : "Contact support to resolve it.";
if (reason === "payment_dispute") return `This account is disabled because of a payment dispute. ${contact}`;
return `This account is disabled. ${contact}`;
}
/** Paths a disabled account's browser can still reach: signing out, the legal pages and the notice itself. */
export function reachableWhileDisabled(pathname: string): boolean {
return ["/logout", "/terms", "/privacy", "/acceptable-use", "/cookies", "/dmca", "/security"].some(
(path) => pathname === path || pathname.startsWith(`${path}/`),
);
}
/** An admin disable is a takedown: the account's profile, activity, avatar and repositories stop serving. */
export function isTakenDown(account: { disabled_at?: number | null; disabled_reason?: string | null }): boolean {
return Boolean(account.disabled_at) && account.disabled_reason === "admin";
}