Edit flow configured
This commit is contained in:
+2
-2
@@ -292,8 +292,8 @@ export type MyPublishedRule = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Lists the signed-in user’s published rules (newest first). Returns `null` on
|
||||
* network failure or unauthenticated response.
|
||||
* Lists the signed-in user’s published rules (**last updated first**, stable by id).
|
||||
* Returns `null` on network failure or unauthenticated response.
|
||||
*/
|
||||
export async function fetchMyPublishedRules(): Promise<
|
||||
MyPublishedRule[] | null
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* Bridges final-review → completed without query strings, and re-opens a rule
|
||||
* from profile (`/create/completed?ruleId=…`) after GET /api/rules/[id].
|
||||
* from profile (`/create/completed?ruleId=…`) after GET /api/rules/[id]. Profile
|
||||
* "Manage" links here; "View" uses `/rules/[id]`.
|
||||
*/
|
||||
export const CREATE_FLOW_LAST_PUBLISHED_KEY = "createFlow.lastPublished";
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Reorders facet-ranked method presets so explicitly confirmed selections pin
|
||||
* to the top while the remainder keeps score-based ranking (recommended before
|
||||
* default).
|
||||
*/
|
||||
|
||||
/** Selected ids first (selection array order); then tail in `ranked` order. */
|
||||
export function orderRankedMethodsWithPinnedSelection<T extends { id: string }>(
|
||||
rankedMethods: readonly T[],
|
||||
selectedIds: readonly string[],
|
||||
pinActive: boolean,
|
||||
): T[] {
|
||||
if (!pinActive || selectedIds.length === 0) {
|
||||
return [...rankedMethods];
|
||||
}
|
||||
const byId = new Map(rankedMethods.map((m) => [m.id, m] as const));
|
||||
const head: T[] = [];
|
||||
const picked = new Set<string>();
|
||||
for (const id of selectedIds) {
|
||||
const row = byId.get(id);
|
||||
if (!row || picked.has(id)) continue;
|
||||
picked.add(id);
|
||||
head.push(row);
|
||||
}
|
||||
const tail = rankedMethods.filter((m) => !picked.has(m.id));
|
||||
return [...head, ...tail];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefer selected ids in compact slots (up to `limit`), then facet-derived
|
||||
* `baseCompact.compactCardIds`, then remaining methods in showcase order so
|
||||
* selected cards surface even when they are outside the unpinned facet top-N.
|
||||
*/
|
||||
export function mergeCompactCardIdsWithPinnedSelected(
|
||||
showcaseOrderIds: readonly string[],
|
||||
baseCompactCardIds: readonly string[],
|
||||
selectedIds: readonly string[],
|
||||
pinActive: boolean,
|
||||
limit: number,
|
||||
): string[] {
|
||||
if (!pinActive || selectedIds.length === 0) {
|
||||
return [...baseCompactCardIds].slice(0, limit);
|
||||
}
|
||||
const valid = new Set(showcaseOrderIds);
|
||||
const out: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
for (const id of selectedIds) {
|
||||
if (out.length >= limit) break;
|
||||
if (!valid.has(id) || seen.has(id)) continue;
|
||||
seen.add(id);
|
||||
out.push(id);
|
||||
}
|
||||
for (const id of baseCompactCardIds) {
|
||||
if (out.length >= limit) break;
|
||||
if (!valid.has(id) || seen.has(id)) continue;
|
||||
seen.add(id);
|
||||
out.push(id);
|
||||
}
|
||||
for (const id of showcaseOrderIds) {
|
||||
if (out.length >= limit) break;
|
||||
if (seen.has(id)) continue;
|
||||
seen.add(id);
|
||||
out.push(id);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user