Add custom intervention modals

This commit is contained in:
adilallo
2026-05-01 22:05:05 -06:00
parent 58d0e33500
commit dee2dd800e
67 changed files with 3480 additions and 197 deletions
@@ -0,0 +1,32 @@
/**
* Merge JSON preset method rows with user-created cards (stable UUID ids + meta).
* Custom rows follow `selectedIds` order (most-recent add at index 0 in create flow)
* but appear after all presets in this merged list; CardStack display order is
* layered separately via `useMethodCardDeckOrdering`.
*/
export function mergePresetMethodsWithCustom<
T extends { id: string; label: string; supportText?: string },
>(
presets: readonly T[],
selectedIds: readonly string[],
meta: Record<string, { label: string; supportText: string }> | undefined,
): T[] {
const presetIds = new Set(presets.map((p) => p.id));
const customRows: T[] = [];
const seenCustom = new Set<string>();
for (const id of selectedIds) {
if (presetIds.has(id)) continue;
const row = meta?.[id];
if (!row || seenCustom.has(id)) continue;
seenCustom.add(id);
customRows.push({
id,
label: row.label,
supportText: row.supportText,
} as T);
}
return [...presets, ...customRows];
}