// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import React from "react"; import { Select } from "@cloudscape-design/components"; import { OptionProps } from "./makeData"; interface Props { options: OptionProps[]; dropdownType: string; onChange: (value: string) => void; selectedOption?: OptionProps; setSelectedOption?: React.Dispatch>; } const Dropdown: React.FC = ({ options, dropdownType, onChange, selectedOption, setSelectedOption }) => { //by defult the root node should be the first option in the table with according tables preloaded if (!selectedOption || !setSelectedOption) { [selectedOption, setSelectedOption] = React.useState({ label: "", value: "" }); // NOSONAR: typescript:S6440 } const handleChange = async (event: any) => { (setSelectedOption as React.Dispatch>)(event.detail.selectedOption); onChange(event.detail.selectedOption.value); }; return ( <>