@@ -4,13 +4,90 @@ import { BiBoltCircle, BiBot, BiFile, BiGroup, BiMessageSquareDots, BiTime, BiUs
44import { useNavigate } from 'react-router-dom'
55import { commandMenuOpenAtom } from './CommandMenu'
66import { PiMagicWand } from 'react-icons/pi'
7- import { LuSquareFunction } from 'react-icons/lu'
7+ import { LuBellDot , LuSquareFunction } from 'react-icons/lu'
88import { AiOutlineApi } from 'react-icons/ai'
9+ import { useMemo } from 'react'
910
10- type Props = { }
11+ type Props = {
12+ text : string
13+ }
1114
1215const ICON_SIZE = 16
1316
17+ const ITEMS = [
18+ {
19+ value : 'profile' ,
20+ label : 'Profile' ,
21+ icon : < BiUserCircle size = { ICON_SIZE } /> ,
22+ } ,
23+ {
24+ value : 'users' ,
25+ label : 'Users' ,
26+ icon : < BiGroup size = { ICON_SIZE } /> ,
27+ } ,
28+ {
29+ value : 'hr' ,
30+ label : 'HR' ,
31+ icon : < svg fill = "none" viewBox = "0 0 32 32" width = { 18 } height = { 18 } xmlns = "http://www.w3.org/2000/svg" >
32+ < g clipPath = "url(#clip0_2850_17380)" >
33+ < path d = "M25.5561 0H6.44394C2.88505 0 0 2.88505 0 6.44394V25.5561C0 29.115 2.88505 32 6.44394 32H25.5561C29.115 32 32 29.115 32 25.5561V6.44394C32 2.88505 29.115 0 25.5561 0Z" fill = "#A1EEC9" > </ path >
34+ < path d = "M15.4061 18.5995C12.4184 18.5995 9.97265 16.1684 9.97265 13.1661V12.6974L12.8724 12.7267L12.8431 13.1661C12.8431 14.572 13.9855 15.729 15.4061 15.729H16.5777C17.9836 15.729 19.1406 14.5867 19.1406 13.1661V11.9944C19.1406 10.5885 17.9983 9.43151 16.5777 9.43151H9.94336L9.97265 6.53174L16.5777 6.56103C19.5653 6.56103 22.0111 8.99215 22.0111 11.9944V13.1661C22.0111 16.1537 19.58 18.5995 16.5777 18.5995H15.4061Z" fill = "#0B313A" > </ path >
35+ < path d = "M8.78613 23.2714C10.7779 21.5286 13.3408 20.5474 16.0063 20.5474C18.6717 20.5474 21.2346 21.5286 23.2264 23.3153L21.2932 25.4389C19.8287 24.1355 17.9541 23.4178 16.0063 23.4178C14.0584 23.4178 12.1692 24.1355 10.7047 25.4535L8.80078 23.2714H8.78613Z" fill = "#0B313A" > </ path >
36+ </ g >
37+ < defs >
38+ < clipPath id = "clip0_2850_17380" >
39+ < rect fill = "white" height = "32" width = "32" > </ rect >
40+ </ clipPath >
41+ </ defs >
42+ </ svg >
43+ } ,
44+ {
45+ value : 'document-notifications' ,
46+ label : 'Document Notifications' ,
47+ icon : < LuBellDot size = { ICON_SIZE } /> ,
48+ } ,
49+ {
50+ value : 'message-actions' ,
51+ label : 'Message Actions' ,
52+ icon : < BiBoltCircle size = { ICON_SIZE } /> ,
53+ } ,
54+ {
55+ value : 'scheduled-messages' ,
56+ label : 'Scheduled Messages' ,
57+ icon : < BiTime size = { ICON_SIZE } /> ,
58+ } ,
59+ {
60+ value : 'webhooks' ,
61+ label : 'Webhooks' ,
62+ icon : < AiOutlineApi size = { ICON_SIZE } /> ,
63+ } ,
64+ {
65+ value : 'bots' ,
66+ label : 'Bots' ,
67+ icon : < BiBot size = { ICON_SIZE } /> ,
68+ } ,
69+ {
70+ value : 'functions' ,
71+ label : 'Functions' ,
72+ icon : < LuSquareFunction size = { ICON_SIZE } /> ,
73+ } ,
74+ {
75+ value : 'instructions' ,
76+ label : 'Instructions' ,
77+ icon : < BiFile size = { ICON_SIZE } /> ,
78+ } ,
79+ {
80+ value : 'commands' ,
81+ label : 'Commands' ,
82+ icon : < BiMessageSquareDots size = { ICON_SIZE } /> ,
83+ } ,
84+ {
85+ value : 'ai-settings' ,
86+ label : 'AI Settings' ,
87+ icon : < PiMagicWand size = { ICON_SIZE } /> ,
88+ } ,
89+ ]
90+
1491const SettingsList = ( props : Props ) => {
1592
1693 const navigate = useNavigate ( )
@@ -21,76 +98,24 @@ const SettingsList = (props: Props) => {
2198 navigate ( `/settings/${ value } ` )
2299 setOpen ( false )
23100 }
24- return (
25- < Command . Group heading = 'Settings' >
26- < Command . Item value = 'profile' onSelect = { onSelect } >
27- < BiUserCircle size = { ICON_SIZE } />
28- Profile
29- </ Command . Item >
30- < Command . Item value = 'users' onSelect = { onSelect } >
31- < BiGroup size = { ICON_SIZE } />
32- Users
33- </ Command . Item >
34- < Command . Item value = 'hr' keywords = { [ 'hr' , 'human resources' , 'Frappe HR' ] } onSelect = { onSelect } >
35- < svg fill = "none" viewBox = "0 0 32 32" width = { 18 } height = { 18 } xmlns = "http://www.w3.org/2000/svg" >
36- < g clipPath = "url(#clip0_2850_17380)" >
37- < path d = "M25.5561 0H6.44394C2.88505 0 0 2.88505 0 6.44394V25.5561C0 29.115 2.88505 32 6.44394 32H25.5561C29.115 32 32 29.115 32 25.5561V6.44394C32 2.88505 29.115 0 25.5561 0Z" fill = "#A1EEC9" > </ path >
38- < path d = "M15.4061 18.5995C12.4184 18.5995 9.97265 16.1684 9.97265 13.1661V12.6974L12.8724 12.7267L12.8431 13.1661C12.8431 14.572 13.9855 15.729 15.4061 15.729H16.5777C17.9836 15.729 19.1406 14.5867 19.1406 13.1661V11.9944C19.1406 10.5885 17.9983 9.43151 16.5777 9.43151H9.94336L9.97265 6.53174L16.5777 6.56103C19.5653 6.56103 22.0111 8.99215 22.0111 11.9944V13.1661C22.0111 16.1537 19.58 18.5995 16.5777 18.5995H15.4061Z" fill = "#0B313A" > </ path >
39- < path d = "M8.78613 23.2714C10.7779 21.5286 13.3408 20.5474 16.0063 20.5474C18.6717 20.5474 21.2346 21.5286 23.2264 23.3153L21.2932 25.4389C19.8287 24.1355 17.9541 23.4178 16.0063 23.4178C14.0584 23.4178 12.1692 24.1355 10.7047 25.4535L8.80078 23.2714H8.78613Z" fill = "#0B313A" > </ path >
40- </ g >
41- < defs >
42- < clipPath id = "clip0_2850_17380" >
43- < rect fill = "white" height = "32" width = "32" > </ rect >
44- </ clipPath >
45- </ defs >
46- </ svg >
47- HR
48- </ Command . Item >
49-
50- < Command . Item value = 'message-actions' onSelect = { onSelect } >
51- < BiBoltCircle size = { ICON_SIZE } />
52- Message Actions
53- </ Command . Item >
54-
55- < Command . Item value = 'scheduled-messages' keywords = { [ 'scheduled messages' ] } onSelect = { onSelect } >
56- < BiTime size = { ICON_SIZE } />
57- Scheduled Messages
58- </ Command . Item >
59101
60- < Command . Item value = 'webhooks' onSelect = { onSelect } >
61- < AiOutlineApi size = { ICON_SIZE } />
62- Webhooks
63- </ Command . Item >
102+ const filteredItems = useMemo ( ( ) => {
103+ return ITEMS . filter ( ( item ) => item . label . toLowerCase ( ) . includes ( props . text . toLowerCase ( ) ) )
104+ } , [ props . text ] )
64105
65- < Command . Item value = 'bots' onSelect = { onSelect } >
66- < BiBot size = { ICON_SIZE } />
67- Bots
68- </ Command . Item >
69-
70- < Command . Item value = 'functions' onSelect = { onSelect } >
71- < LuSquareFunction size = { ICON_SIZE } />
72- Functions
73- </ Command . Item >
74-
75- < Command . Item value = 'instructions' onSelect = { onSelect } >
76- < BiFile size = { ICON_SIZE } />
77- Instructions
78- </ Command . Item >
79-
80- < Command . Item value = 'document-processors' onSelect = { onSelect } >
81- < BiFile size = { ICON_SIZE } />
82- Document Processors
83- </ Command . Item >
106+ if ( filteredItems . length === 0 ) {
107+ return null
108+ }
84109
85- < Command . Item value = 'commands' onSelect = { onSelect } >
86- < BiMessageSquareDots size = { ICON_SIZE } />
87- Commands
88- </ Command . Item >
89110
90- < Command . Item value = 'ai-settings' onSelect = { onSelect } >
91- < PiMagicWand size = { ICON_SIZE } />
92- AI Settings
93- </ Command . Item >
111+ return (
112+ < Command . Group heading = 'Settings' >
113+ { filteredItems . map ( ( item ) => (
114+ < Command . Item key = { item . value } value = { item . value } onSelect = { onSelect } >
115+ { item . icon }
116+ { item . label }
117+ </ Command . Item >
118+ ) ) }
94119 </ Command . Group >
95120 )
96121}
0 commit comments