docs: use Kapa React SDK (#12792)

This commit is contained in:
Shahed Nasser
2025-06-20 18:24:14 +03:00
committed by GitHub
parent 77d0f00929
commit ab21ac57ca
27 changed files with 462 additions and 875 deletions
@@ -1,12 +1,12 @@
"use client"
import Link from "next/link"
import React from "react"
import React, { useMemo } from "react"
import { MarkdownIcon } from "../../Icons/Markdown"
import { useAiAssistant, useSiteConfig } from "../../../providers"
import { usePathname } from "next/navigation"
import { BroomSparkle } from "@medusajs/icons"
import { useAiAssistantChat } from "../../../providers/AiAssistant/Chat"
import { useChat } from "@kapaai/react-sdk"
export const ContentMenuActions = () => {
const {
@@ -14,14 +14,18 @@ export const ContentMenuActions = () => {
} = useSiteConfig()
const pathname = usePathname()
const { setChatOpened } = useAiAssistant()
const { setQuestion, loading } = useAiAssistantChat()
const { isGeneratingAnswer, isPreparingAnswer, submitQuery } = useChat()
const loading = useMemo(
() => isGeneratingAnswer || isPreparingAnswer,
[isGeneratingAnswer, isPreparingAnswer]
)
const pageUrl = `${baseUrl}${basePath}${pathname}`
const handleAiAssistantClick = () => {
if (loading) {
return
}
setQuestion(`Explain the page ${pageUrl}`)
submitQuery(`Explain the page ${pageUrl}`)
setChatOpened(true)
}