index.tsx40 lines · main
1import { AiIconAnimation } from 'ui'
2
3import { useRegisterCommands } from '../../api/hooks/commandsHooks'
4import { useRegisterPage, useSetPage } from '../../api/hooks/pagesHooks'
5import type { CommandOptions, ICommand } from '../../api/types'
6import { PageType } from '../../api/utils'
7import { DocsAiPage } from './DocsAiPage'
8
9const DOCS_AI_COMMANDS = {
10 PAGE_NAME: 'Ask Briven AI',
11 SECTION_NAME: 'Docs',
12}
13
14const identity = <T,>(x: T) => x
15
16const useDocsAiCommands = ({
17 modify = identity,
18 options,
19}: { modify?: (command: ICommand) => ICommand; options?: CommandOptions } = {}) => {
20 const setCommandPage = useSetPage()
21
22 useRegisterPage(DOCS_AI_COMMANDS.PAGE_NAME, { type: PageType.Component, component: DocsAiPage })
23
24 useRegisterCommands(
25 DOCS_AI_COMMANDS.SECTION_NAME,
26 [
27 {
28 id: 'ai-docs',
29 name: 'Ask Briven AI',
30 action: () => {
31 setCommandPage(DOCS_AI_COMMANDS.PAGE_NAME, true)
32 },
33 icon: () => <AiIconAnimation />,
34 },
35 ].map(modify),
36 options
37 )
38}
39
40export { useDocsAiCommands }