Import the remade decks on stable ids and recommend one card per job, so a saved draft still loads after a chip is renamed.

The real-group profiles stay as a test, so a change that moves a pick fails.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
adilalloandCursor committed 2026-11-04 14:22:54 -07:00
1 parent 96ca15d8e3
commit bcbc6f30d9
89 files changed
+36555 -2828

No files matched your search

+47 -20
View File
@@ -5,6 +5,7 @@ import type {
} from "../../app/components/type/CommunityRule/CommunityRule.types";
import type { PublishedMethodSelections } from "./buildPublishPayload";
import type { CustomMethodCardFieldBlock } from "./customMethodCardFieldBlocks";
import decisionApproachesMessages from "../../messages/en/create/customRule/decisionApproaches.json";
import { decisionApproachScopeForPublish } from "./decisionApproachKeyResources";
import { templateCategoryToGroupKey } from "./templateReviewMapping";
@@ -77,6 +78,11 @@ export function labeledBlocksFromCustomMethodCardFieldBlocks(
export type CommunityRuleEntryFromChipOptions = {
consensusLevelKey?: string;
/**
* Copy used when `consensusLevel` is absent. `null` means the figure was
* dropped on purpose (a seeded share on an empty custom card) and must not print.
*/
missingConsensusBody?: string | null;
customFieldBlocks?: CustomMethodCardFieldBlock[];
/** Wizard step-2 policy description (`customMethodCardMetaById.supportText`). */
supportText?: string;
@@ -92,32 +98,42 @@ export const RULE_SECTION_CATEGORY = {
} as const;
const COMM_LABELS: Record<string, string> = {
corePrinciple: "Core Principle & Scope",
logisticsAdmin: "Logistics, Admin & Norms",
codeOfConduct: "Code of Conduct",
corePrinciple: "Core principle and scope",
logisticsAdmin: "How it works",
codeOfConduct: "Norms",
};
const MEM_LABELS: Record<string, string> = {
eligibility: "Eligibility & Philosophy",
joiningProcess: "Joining Process",
expectations: "Expectations & Removal",
eligibility: "Who it covers and why",
joiningProcess: "How it works",
expectations: "Expectations and limits",
};
const DEC_LABELS: Record<string, string> = {
corePrinciple: "Core Principle",
applicableScope: "Applicable Scope",
stepByStepInstructions: "Step-by-Step Instructions",
consensusLevel: "Consensus Level",
objectionsDeadlocks: "Objections & Deadlocks",
corePrinciple: "Core principle",
applicableScope: "Applicable scope",
stepByStepInstructions: "Step-by-step instructions",
consensusLevel: "Consensus level",
objectionsDeadlocks: "Objections and deadlocks",
};
const CM_LABELS: Record<string, string> = {
corePrinciple: "Core Principle",
applicableScope: "Applicable Scope",
processProtocol: "Process Protocol",
restorationFallbacks: "Restoration & Fallbacks",
corePrinciple: "Core principle",
applicableScope: "Applicable scope",
processProtocol: "How it works",
restorationFallbacks: "Protections and fallbacks",
};
function consensusLevelBody(
value: unknown,
whenMissing: string | null,
): string | null {
const copy = decisionApproachesMessages.consensusLevelDisplay;
if (typeof value !== "number" || Number.isNaN(value)) return whenMissing;
if (value === 0) return copy.noSetShare;
return `${value}%`;
}
export function nonEmptyTrimmed(s: unknown): string | null {
if (typeof s !== "string") return null;
const t = s.trim();
@@ -158,15 +174,18 @@ export function blocksFromKeyedRecord(
labelByKey: Record<string, string>,
options?: {
consensusLevelKey?: string;
missingConsensusBody?: string | null;
},
): CommunityRuleLabeledBlock[] {
const blocks: CommunityRuleLabeledBlock[] = [];
const whenMissing =
options?.missingConsensusBody === undefined
? decisionApproachesMessages.consensusLevelDisplay.supermajorityShare
: options.missingConsensusBody;
for (const [key, label] of Object.entries(labelByKey)) {
if (options?.consensusLevelKey === key) {
const n = sections[key];
if (typeof n === "number" && !Number.isNaN(n)) {
blocks.push({ label, body: `${n}%` });
}
const body = consensusLevelBody(sections[key], whenMissing);
if (body) blocks.push({ label, body });
continue;
}
const raw = sections[key];
@@ -189,7 +208,10 @@ export function communityRuleEntryFromMethodChip(
sections,
labelByKey,
options?.consensusLevelKey
? { consensusLevelKey: options.consensusLevelKey }
? {
consensusLevelKey: options.consensusLevelKey,
missingConsensusBody: options.missingConsensusBody,
}
: undefined,
);
const wizardBlocks =
@@ -323,6 +345,11 @@ export function sectionFromDecision(
DEC_LABELS,
{
consensusLevelKey: "consensusLevel",
missingConsensusBody:
typeof sec.consensusLevel === "number" &&
!Number.isNaN(sec.consensusLevel)
? null
: undefined,
customFieldBlocks: customFieldBlocksById?.[m.id],
supportText: m.supportText,
},