forked from dpim/wf-react-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctionSelector.tsx
More file actions
44 lines (40 loc) · 1.27 KB
/
functionSelector.tsx
File metadata and controls
44 lines (40 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from 'react'
import Dropdown from './dropdown'
// Define the type for the options used in the dropdowns
interface Option {
value: string
label: string
}
// Define the props for the FunctionSelector component
interface FunctionSelectorProps {
exampleCategories: Option[] // Array of options for categories
functionSelections: Option[] // Array of options for functions
selectedExampleCategory: string // The currently selected category
selectedFunctionName: string // The currently selected function name
onCategoryChange: (value: string) => void // Handler for when the category changes
onFunctionChange: (value: string) => void // Handler for when the function changes
}
const FunctionSelector: React.FC<FunctionSelectorProps> = ({
exampleCategories,
functionSelections,
selectedExampleCategory,
selectedFunctionName,
onCategoryChange,
onFunctionChange,
}) => (
<>
<p>Select an API category</p>
<Dropdown
options={exampleCategories}
selectedValue={selectedExampleCategory}
onValueChange={onCategoryChange}
/>
<p>Select an API method</p>
<Dropdown
options={functionSelections}
selectedValue={selectedFunctionName}
onValueChange={onFunctionChange}
/>
</>
)
export default FunctionSelector