1 "use client"
2
3 import React from "react"
4 import { useInstantSearch } from "react-instantsearch"
5 import { useMedusaSuggestions } from "../../../hooks/use-medusa-suggestions"
6 import { Card } from "../../Card"
7 import { useAnalytics } from "../../../providers/Analytics"
8 import { DocsTrackingEvents } from "../../../constants"
9
10 export const SearchCallout = () => {
11 const { results } = useInstantSearch()
12 const query = results?.query || ""
13 const matchedCallout = useMedusaSuggestions({ keywords: query })
14 const { track } = useAnalytics()
15
16 if (!matchedCallout) {
17 return null
18 }
19
20 return (
21 <div className="m-docs_1 flex justify-center items-center">
22 <Card
23 {...matchedCallout}
24 type="bloom"
25 onClick={() => {
26 track({
27 event: {
28 event: DocsTrackingEvents.SEARCH_CALLOUT_CLICK,
29 options: {
30 user_keywords: query,
31 callout_title: matchedCallout.title,
32 callout_href: matchedCallout.href,
33 },
34 },
35 })
36 }}
37 />
38 </div>
39 )
40 }