diff --git a/app/canvas/[id]/canvas-client.tsx b/app/canvas/[id]/canvas-client.tsx index 52c319e..b79b93f 100644 --- a/app/canvas/[id]/canvas-client.tsx +++ b/app/canvas/[id]/canvas-client.tsx @@ -62,6 +62,17 @@ export function CanvasClient({ canvas, initialCards }: CanvasClientProps) { const totalResults = cards.length + /** + * Fetch recommendations for a list of card IDs and update the state accordingly. + * + * The function iterates over each cardId, makes an API call to fetch recommendations, and collects the results. + * If the response is successful, it stores the recommendations in an entries array. After processing all cardIds, + * it updates the card recommendations state, either replacing the existing entries or merging them based on the options provided. + * + * @param cardIds - An array of card IDs for which recommendations are to be fetched. + * @param options - An optional object that may contain a replace flag to determine if existing recommendations should be replaced. + * @returns void + */ const fetchRecommendations = async (cardIds: string[], options: { replace?: boolean } = {}) => { const entries: [string, Recommendation[]][] = []