Skip setup questions on the template path and collect name, photo, and description without recommendations.
Customize opens a dialog then walks the template decks; Use without changes lands on final review with Has Name Field. Template cards stay first, the engine is not called, and the catalog no longer shows a recommended tag.
This commit is contained in:
1 parent
53d236d0d5
commit
6498d52541
37 files changed
+1450
-733
No files matched your search
@@ -8,7 +8,11 @@ import {
|
||||
groupAnswersForRecommendations,
|
||||
type RecommendationSection,
|
||||
} from "./useFacetRecommendations";
|
||||
import { deckData } from "../../../../lib/create/deckRecommend";
|
||||
import { deckData, templateDeck } from "../../../../lib/create/deckRecommend";
|
||||
import {
|
||||
templateCardIdsForDeck,
|
||||
templatePathFromState,
|
||||
} from "../../../../lib/create/templatePath";
|
||||
import { useCreateFlow } from "../context/CreateFlowContext";
|
||||
import { useMessages } from "../../../contexts/MessagesContext";
|
||||
|
||||
@@ -30,6 +34,8 @@ function orderByIds<T extends { id: string }>(
|
||||
/**
|
||||
* Deck order and the compact stack come from the job rule. Compact shows
|
||||
* at most seven recommended cards. Selected cards still pin into the stack.
|
||||
* On the template path the engine is not called: template cards first, then
|
||||
* the rest of the deck, with no tag and no seven-card cut.
|
||||
*/
|
||||
export function useMethodCardDeckOrdering(
|
||||
section: RecommendationSection,
|
||||
@@ -38,15 +44,32 @@ export function useMethodCardDeckOrdering(
|
||||
) {
|
||||
const { state } = useCreateFlow();
|
||||
const copy = useMessages().create.customRule.recommendations;
|
||||
const compactLimit = deckData(section).config.displayLimit;
|
||||
const templateSlug = templatePathFromState(state)?.slug;
|
||||
const engineCompactLimit = deckData(section).config.displayLimit;
|
||||
const answers = useMemo(
|
||||
() => groupAnswersForRecommendations(state),
|
||||
[state],
|
||||
);
|
||||
const deck = useMemo(
|
||||
() => deriveCompactCards(section, answers, compactLimit),
|
||||
[section, answers, compactLimit],
|
||||
);
|
||||
const deck = useMemo(() => {
|
||||
if (templateSlug) {
|
||||
const templateIds = templateCardIdsForDeck(templateSlug, section);
|
||||
const firstIds =
|
||||
templateIds.length > 0 ? templateIds : [...selectedIds];
|
||||
const ordered = templateDeck(deckData(section), firstIds);
|
||||
const orderedIds = [...ordered.first, ...ordered.rest];
|
||||
return {
|
||||
compactCardIds: orderedIds,
|
||||
recommendedIds: new Set<string>(),
|
||||
orderedIds,
|
||||
fallback: true,
|
||||
recommendedById: new Map(),
|
||||
};
|
||||
}
|
||||
return deriveCompactCards(section, answers, engineCompactLimit);
|
||||
}, [answers, engineCompactLimit, section, selectedIds, templateSlug]);
|
||||
const compactLimit = templateSlug
|
||||
? deck.orderedIds.length
|
||||
: engineCompactLimit;
|
||||
|
||||
const rankedMethods = useMemo(
|
||||
() => orderByIds(methods, deck.orderedIds),
|
||||
|
||||
Reference in new issue
Block a user