1- import React from 'react' ;
1+ import React , { useState } from 'react' ;
22import { useDispatch , useSelector } from "react-redux" ;
33import { updateSettings } from "../store/slices/searchApplicationSettingsSlice" ;
44import { useToast } from "../contexts/ToastContext" ;
55import { MessageType } from "./Toast" ;
66import { RootState } from "../store/store" ;
7+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
8+ import { faAngleDown , faAngleUp } from "@fortawesome/free-solid-svg-icons" ;
9+
710
811const SearchApplicationSettings : React . FC = ( ) => {
912 const dispatch = useDispatch ( ) ;
10- const { appName, apiKey, searchEndpoint} = useSelector ( ( state : RootState ) => state . searchApplicationSettings ) ;
13+ const { appName, apiKey, searchEndpoint, searchPersona } = useSelector ( ( state : RootState ) => state . searchApplicationSettings ) ;
1114 const { showToast} = useToast ( ) ;
15+ const searchPersonaOptions = [
16+ "admin" ,
17+ "user"
18+ ]
19+ const [ isOpen , setIsOpen ] = useState ( false ) ;
20+
21+ const toggleDropdown = ( ) => {
22+ setIsOpen ( ! isOpen ) ;
23+ } ;
24+
25+ const handlePersonaChange = ( value : string ) => {
26+ updateSearchPersona ( value ) ;
27+ } ;
1228
1329 const handleSave = ( ) => {
14- dispatch ( updateSettings ( { appName, apiKey, searchEndpoint} ) ) ;
30+ dispatch ( updateSettings ( { appName, apiKey, searchEndpoint, searchPersona } ) ) ;
1531 showToast ( "Settings saved!" , MessageType . Info ) ;
1632 } ;
1733
18- const updateAppName = ( e ) => dispatch ( updateSettings ( { appName : e . target . value , apiKey, searchEndpoint} ) )
19- const updateApiKey = ( e ) => dispatch ( updateSettings ( { appName, apiKey : e . target . value , searchEndpoint} ) )
20- const updateSearchEndpoint = ( e ) => dispatch ( updateSettings ( { appName, apiKey, searchEndpoint : e . target . value } ) )
34+ const updateAppName = ( e ) => dispatch ( updateSettings ( { appName : e . target . value , apiKey, searchEndpoint, searchPersona} ) )
35+ const updateApiKey = ( e ) => dispatch ( updateSettings ( { appName, apiKey : e . target . value , searchEndpoint, searchPersona} ) )
36+ const updateSearchEndpoint = ( e ) => dispatch ( updateSettings ( { appName, apiKey, searchEndpoint : e . target . value , searchPersona} ) )
37+
38+ const updateSearchPersona = ( e ) => dispatch ( updateSettings ( { appName, apiKey, searchEndpoint, searchPersona : e } ) )
2139
2240 return (
2341 < div className = "container mx-auto p-4 bg-white rounded shadow-md" >
@@ -54,9 +72,9 @@ const SearchApplicationSettings: React.FC = () => {
5472 htmlFor = "apiKey"
5573 className = "block text-sm font-medium mb-1 text-gray-700"
5674 >
57- API Key:
75+ Application API Key:
5876 </ label >
59- < p className = "text-xs mb-2 text-gray-500" > Your unique API key used for authentication .</ p >
77+ < p className = "text-xs mb-2 text-gray-500" > Your application's unique API key used for looking up identities .</ p >
6078 < input
6179 id = "apiKey"
6280 type = "password"
@@ -83,6 +101,29 @@ const SearchApplicationSettings: React.FC = () => {
83101 />
84102 </ div >
85103
104+ < div className = "text-left mb-6 p-4 border rounded bg-gray-50" >
105+ < label
106+ htmlFor = "searchPersona"
107+ className = "block text-sm font-medium mb-1 text-gray-700"
108+ >
109+ Search Persona:
110+ </ label >
111+ < p className = "text-xs mb-2 text-gray-500" > The persona on whose behalf searches will be executed</ p >
112+ < div className = "relative" >
113+ < select
114+ onChange = { ( event ) => handlePersonaChange ( event . target . value ) }
115+ className = "flex items-center space-x-2 p-2 bg-white rounded border border-gray-300 focus:outline-none focus:border-blue-500"
116+ >
117+ { searchPersonaOptions . map ( ( option , index ) => (
118+ < option value = { option } className = "block text-left p-2 hover:bg-gray-100 cursor-pointer" >
119+ { option }
120+ </ option >
121+ ) ) }
122+ </ select >
123+ </ div >
124+ </ div >
125+
126+
86127 < button
87128 onClick = { handleSave }
88129 className = "mt-4 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
0 commit comments