File size: 2,077 Bytes
87337b1 |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
"use client"
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import {
useAppDispatch,
LANGUAGE_OPTIONS,
useAppSelector,
GRAPH_OPTIONS,
} from "@/common"
import type { Language } from "@/types"
import { setGraphName, setLanguage } from "@/store/reducers/global"
export function GraphSelect() {
const dispatch = useAppDispatch()
const graphName = useAppSelector((state) => state.global.graphName)
const agentConnected = useAppSelector((state) => state.global.agentConnected)
const onGraphNameChange = (val: string) => {
dispatch(setGraphName(val))
}
return (
<>
<Select
value={graphName}
onValueChange={onGraphNameChange}
disabled={agentConnected}
>
<SelectTrigger className="w-auto max-w-full">
<SelectValue placeholder="Graph" />
</SelectTrigger>
<SelectContent>
{GRAPH_OPTIONS.map((item) => {
return (
<SelectItem value={item.value} key={item.value}>
{item.label}
</SelectItem>
)
})}
</SelectContent>
</Select>
</>
)
}
export function LanguageSelect() {
const dispatch = useAppDispatch()
const language = useAppSelector((state) => state.global.language)
const agentConnected = useAppSelector((state) => state.global.agentConnected)
const onLanguageChange = (val: Language) => {
dispatch(setLanguage(val))
}
return (
<>
<Select
value={language}
onValueChange={onLanguageChange}
disabled={agentConnected}
>
<SelectTrigger className="w-32">
<SelectValue placeholder="Language" />
</SelectTrigger>
<SelectContent>
{LANGUAGE_OPTIONS.map((item) => {
return (
<SelectItem value={item.value} key={item.value}>
{item.label}
</SelectItem>
)
})}
</SelectContent>
</Select>
</>
)
}
|