@@ -3,15 +3,15 @@ import { useState } from "react";
33import { Button } from "../ui/button" ;
44import { Sparkles , Loader2 } from "lucide-react" ;
55import AISuggestionDialog from "./ai-suggestions-dialog" ;
6- import { getConceptRecommendationsUnison } from "@/api/recommendations" ;
6+ import { getRecommendations } from "@/api/recommendations" ;
77import { addConcept } from "@/api/concepts" ;
88import { toast } from "sonner" ;
99import {
1010 DropdownMenu ,
1111 DropdownMenuContent ,
1212 DropdownMenuLabel ,
1313 DropdownMenuSeparator ,
14- DropdownMenuTrigger
14+ DropdownMenuTrigger ,
1515} from "@/components/ui/dropdown-menu" ;
1616import { domains } from "@/constants/domains" ;
1717import { DropdownMenuItem } from "@radix-ui/react-dropdown-menu" ;
@@ -20,7 +20,7 @@ export function AISuggestionsButton({
2020 value,
2121 tableId,
2222 rowId,
23- contentType
23+ contentType,
2424} : {
2525 value : string ;
2626 tableId : string ;
@@ -29,7 +29,8 @@ export function AISuggestionsButton({
2929} ) {
3030 const [ isLoading , setIsLoading ] = useState ( false ) ;
3131 const [ isOpen , setIsOpen ] = useState ( false ) ;
32- const [ suggestions , setSuggestions ] = useState < UnisonConceptItem [ ] > ( [ ] ) ;
32+ const [ suggestions , setSuggestions ] = useState < RecommendationItem [ ] > ( [ ] ) ;
33+ const [ metadata , setMetadata ] = useState < RecommendationMetadata | null > ( null ) ;
3334 const [ domainId , setDomainId ] = useState < string > ( "" ) ;
3435
3536 // Fetches AI suggestions from the API
@@ -42,14 +43,16 @@ export function AISuggestionsButton({
4243 setIsLoading ( true ) ;
4344
4445 try {
45- // Call the getConceptRecommendations function
46- const recommendations : UnisonConceptResponse =
47- await getConceptRecommendationsUnison ( value , domainId ) ;
46+ const recommendations : RecommendationServiceResponse =
47+ await getRecommendations ( value , domainId ) ;
4848 // Filter to get only unique concept IDs
4949 const uniqueRecommendations = recommendations . items . filter (
5050 ( item , index , array ) =>
5151 array . findIndex ( ( i ) => i . conceptId === item . conceptId ) === index
5252 ) ;
53+ if ( recommendations . metadata ) {
54+ setMetadata ( recommendations . metadata ) ;
55+ }
5356
5457 setSuggestions ( uniqueRecommendations ) ;
5558 setIsOpen ( true ) ;
@@ -136,6 +139,7 @@ export function AISuggestionsButton({
136139 rowId = { rowId }
137140 domainId = { domainId }
138141 contentType = { contentType }
142+ metadata = { metadata }
139143 />
140144 </ >
141145 ) ;
0 commit comments