Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/canvas/[id]/canvas-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[]][] = []

Expand Down