All files / src/pages/flowsheet-page/economics/cost-curves/authoring EvaluationKindField.tsx

95.23% Statements 20/21
70.58% Branches 12/17
33.33% Functions 1/3
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                        16x                             17x       32x   1x     16x 16x     16x 19x 1x             16x 80x 18x 64x      
import { Label } from "@/ahuora-design-system/ui/label";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/ahuora-design-system/ui/select";
import { EvaluationKindEnum } from "@/api/apiStore.gen";
import { WARNING_INVALID_CLASS } from "../ui/constants";
import { FieldError } from "../ui/FieldError";
 
export function EvaluationKindField({
  id,
  value,
  disabled,
  error,
  onChange,
}: {
  id: string;
  value: EvaluationKindEnum;
  disabled?: boolean;
  error?: string;
  onChange: (value: EvaluationKindEnum) => void;
}) {
  return (
    <div className="grid gap-2">
      <Label htmlFor={id}>Evaluation mode</Label>
      <Select
        value={value}
        disabled={disabled}
        onValueChange={(nextValue) => onChange(nextValue as EvaluationKindEnum)}
      >
        <SelectTrigger
          id={id}
          aria-label="Evaluation mode"
          aria-invalid={Boolean(error)}
          aria-describedby={error ? `${id}-error` : undefined}
          className={WARNING_INVALID_CLASS}
        >
          <SelectValue />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value={EvaluationKindEnum.Expression}>
            expression
          </SelectItem>
          <SelectItem value={EvaluationKindEnum.DiscreteFamily}>
            discrete family
          </SelectItem>
        </SelectContent>
      </Select>
      <FieldError id={`${id}-error`} message={error} />
    </div>
  );
}