|
1 | | -import { SegmentedControl, Tip } from '@neo4j-ndl/react'; |
2 | | -import { ChatModeOptions } from '../../utils/Constants'; |
3 | 1 | import { useFileContext } from '../../context/UsersFiles'; |
4 | | -import { DbmsIcon } from '@neo4j-ndl/react/icons'; |
5 | | -import { capitalize } from '@mui/material'; |
| 2 | +import CustomMenu from '../UI/Menu'; |
6 | 3 |
|
7 | | -export default function ChatModeToggle({ inSidenav = false }) { |
8 | | - const [vector, _] = ChatModeOptions; |
9 | | - const { chatMode, setchatMode } = useFileContext(); |
| 4 | +export default function ChatModeToggle({ |
| 5 | + menuAnchor, |
| 6 | + closeHandler = () => {}, |
| 7 | + open, |
| 8 | + anchorPortal = true, |
| 9 | + disableBackdrop = false, |
| 10 | +}: { |
| 11 | + menuAnchor: HTMLElement | null; |
| 12 | + closeHandler?: () => void; |
| 13 | + open: boolean; |
| 14 | + anchorPortal?: boolean; |
| 15 | + disableBackdrop?: boolean; |
| 16 | +}) { |
| 17 | + const { setchatMode, chatMode } = useFileContext(); |
10 | 18 |
|
11 | 19 | return ( |
12 | | - <SegmentedControl |
13 | | - className={inSidenav ? 'flex-col !h-full !ml-1' : ''} |
14 | | - onChange={setchatMode} |
15 | | - hasOnlyIcons={true} |
16 | | - selected={chatMode} |
17 | | - size={'large'} |
18 | | - > |
19 | | - {ChatModeOptions.map((i, idx) => { |
20 | | - return ( |
21 | | - <Tip key={`insidenav${idx}`} allowedPlacements={inSidenav ? ['left'] : ['bottom']}> |
22 | | - <Tip.Trigger> |
23 | | - <SegmentedControl.Item |
24 | | - className={ |
25 | | - idx == ChatModeOptions.length - 1 && inSidenav |
26 | | - ? '!h-[85px]' |
27 | | - : idx == ChatModeOptions.length - 1 |
28 | | - ? '!w-[80px]' |
29 | | - : '' |
30 | | - } |
31 | | - value={i.value} |
32 | | - > |
33 | | - {i.Icon === 'abc' ? ( |
34 | | - <span className={!inSidenav ? 'flex justify-center' : ''}> |
35 | | - <DbmsIcon className='n-size-token-7' /> |
36 | | - <span>+</span> |
37 | | - <vector.Icon className='n-size-token-7' /> |
38 | | - </span> |
39 | | - ) : ( |
40 | | - <i.Icon className='n-size-token-7' /> |
41 | | - )} |
42 | | - </SegmentedControl.Item> |
43 | | - </Tip.Trigger> |
44 | | - <Tip.Content className={!inSidenav ? `!z-[61]` : ''}>{capitalize(i.value)}</Tip.Content> |
45 | | - </Tip> |
46 | | - ); |
47 | | - })} |
48 | | - </SegmentedControl> |
| 20 | + <CustomMenu |
| 21 | + closeHandler={closeHandler} |
| 22 | + open={open} |
| 23 | + MenuAnchor={menuAnchor} |
| 24 | + anchorPortal={anchorPortal} |
| 25 | + disableBackdrop={disableBackdrop} |
| 26 | + items={[ |
| 27 | + { |
| 28 | + title: 'Vector', |
| 29 | + onClick: () => { |
| 30 | + setchatMode('vector'); |
| 31 | + }, |
| 32 | + disabledCondition: false, |
| 33 | + description: `${chatMode === 'vector' ? 'selected' : ''}`, |
| 34 | + }, |
| 35 | + { |
| 36 | + title: 'Vector + Graph', |
| 37 | + onClick: () => { |
| 38 | + setchatMode('graph+vector'); |
| 39 | + }, |
| 40 | + disabledCondition: false, |
| 41 | + description: `${chatMode === 'graph+vector' ? 'selected' : ''}`, |
| 42 | + }, |
| 43 | + ]} |
| 44 | + ></CustomMenu> |
49 | 45 | ); |
50 | 46 | } |
0 commit comments