File size: 1,249 Bytes
246d201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Autocomplete, AutocompleteItem } from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import { I18nKey } from "#/i18n/declaration";

interface AgentInputProps {
  isDisabled: boolean;
  defaultValue: string;
  agents: string[];
}

export function AgentInput({

  isDisabled,

  defaultValue,

  agents,

}: AgentInputProps) {
  const { t } = useTranslation();

  return (
    <fieldset data-testid="agent-selector" className="flex flex-col gap-2">

      <label htmlFor="agent" className="font-[500] text-[#A3A3A3] text-xs">

        {t(I18nKey.SETTINGS_FORM$AGENT_LABEL)}

      </label>

      <Autocomplete

        isDisabled={isDisabled}

        isRequired

        id="agent"

        aria-label="Agent"

        data-testid="agent-input"

        name="agent"

        defaultSelectedKey={defaultValue}

        isClearable={false}

        inputProps={{

          classNames: {

            inputWrapper: "bg-[#27272A] rounded-md text-sm px-3 py-[10px]",

          },

        }}

      >

        {agents.map((agent) => (

          <AutocompleteItem key={agent} value={agent}>

            {agent}

          </AutocompleteItem>

        ))}

      </Autocomplete>

    </fieldset>
  );
}