index.tsx40 lines · main
| 1 | import { AiIconAnimation } from 'ui' |
| 2 | |
| 3 | import { useRegisterCommands } from '../../api/hooks/commandsHooks' |
| 4 | import { useRegisterPage, useSetPage } from '../../api/hooks/pagesHooks' |
| 5 | import type { CommandOptions, ICommand } from '../../api/types' |
| 6 | import { PageType } from '../../api/utils' |
| 7 | import { DocsAiPage } from './DocsAiPage' |
| 8 | |
| 9 | const DOCS_AI_COMMANDS = { |
| 10 | PAGE_NAME: 'Ask Briven AI', |
| 11 | SECTION_NAME: 'Docs', |
| 12 | } |
| 13 | |
| 14 | const identity = <T,>(x: T) => x |
| 15 | |
| 16 | const 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 | |
| 40 | export { useDocsAiCommands } |