diff --git a/src/app/components/portfolio/UploadCsvModal.tsx b/src/app/components/portfolio/UploadCsvModal.tsx index 1a26991..0bfec48 100644 --- a/src/app/components/portfolio/UploadCsvModal.tsx +++ b/src/app/components/portfolio/UploadCsvModal.tsx @@ -7,15 +7,7 @@ import ModalSubmit from "@/app/components/home/ModalSubmit"; import { Input } from "@/app/shadcn_components/ui/input"; import { Label } from "@/app/shadcn_components/ui/label"; -import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectLabel, - SelectTrigger, - SelectValue, -} from "@/app/shadcn_components/ui/select"; +import { set } from "cypress/types/lodash"; export function InputFile() { return ( @@ -26,24 +18,29 @@ export function InputFile() { ); } -interface SelectDropdownProps { - options: string[]; - placeholder: string; - onValueChange: (value: string) => void; -} +type Option = { + label: string; + value: string; +}; + +type DropdownProps = { + options: Option[]; + selectedOption: string; + onSelectOption: (option: Option) => void; +}; export function SelectDropdown({ options, - placeholder, - onValueChange, -}: SelectDropdownProps) { + selectedOption, + onSelectOption, +}: DropdownProps) { return ( - - {placeholder} + + {selectedOption || "Select an option"} @@ -56,17 +53,19 @@ export function SelectDropdown({ leaveFrom="opacity-100 scale-100" leaveTo="opacity-0 scale-95" > - - {options.map((option, idx) => ( - + + {options.map((option) => ( + {({ active }) => ( )} @@ -81,8 +80,49 @@ export function SelectDropdown({ const hiddenInputArrows = "[-moz-appearance:_textfield] [&::-webkit-inner-spin-button]:m-0 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:m-0 [&::-webkit-outer-spin-button]:appearance-none"; -const selectFundingSchemeOptions = ["None", "SHDF", "ECO4"]; -const selectGoalOptions = ["None", "Increase EPC", "Reduce energy consumption"]; +const selectFundingSchemeOptions = [ + { + label: "None", + value: "None", + }, + { + label: "SHDF", + value: "SHDF", + }, + { + label: "ECO4", + value: "ECO4", + }, +]; +const selectGoalOptions = [ + // { + // label: "None", + // value: "None", + // }, + { + label: "Increase EPC", + value: "Increase EPC", + }, + { + label: "Reduce energy consumption", + value: "Reduce energy consumption", + }, +]; + +const goalValueOptions = [ + { + label: "C", + value: "C", + }, + { + label: "B", + value: "B", + }, + { + label: "A", + value: "A", + }, +]; export default function UploadCsvModal({ isOpen = false, @@ -91,47 +131,33 @@ export default function UploadCsvModal({ isOpen?: boolean; setIsOpen: (isOpen: boolean) => void; }) { - // There is a lingering issue with selecting a dropdown inside of a dialog - // https://github.com/radix-ui/primitives/issues/1658 - // This issue will affect shadcn since it's built on top of radix - // The problem comes strictly from the select component propagating clicks to the dialog being, causing the - // dialog to close - - const [portfolioName, setPortfolioName] = useState(""); const [budget, setBudget] = useState(undefined); - const [selectedOutcome, setSelectedOutcome] = - useState("Nothing Specific"); + const [buttonDisabled, setButtonDisabled] = useState(true); const [selectedGoal, setSelectedGoal] = useState(""); - const [selectedEPC, setSelectedEPC] = useState(""); - - function closeModal() { - setIsOpen(false); - } - - // function handlePortfolioNameChange(e: React.ChangeEvent) { - // if (e.target.value.length > 0) { - // setButtonDisabled(false); - // } else { - // setButtonDisabled(true); - // } - // setPortfolioName(e.target.value); - // } + const [fundingScheme, setFundingScheme] = useState(""); + const [goalValue, setGoalValue] = useState(""); function handleGoalChange(value: string) { - // e.stopPropagation(); - console.log(value); setSelectedGoal(value); } - function handleFundingSchemeChange(e: React.ChangeEvent) { - setSelectedEPC(e.target.value); + function handleFundingSchemeChange(value: string) { + setFundingScheme(value); + } + + function handleBudgeChange(e: React.ChangeEvent) { + setBudget(e.target.valueAsNumber); } return ( <> - + setIsOpen(false)} + > Upload a CSV of properties -
-
- -

- If you don't set a budget, we will aim to minimise cost - anyway -

- handlePortfolioNameChange(e)} - className="p-2 border border-gray-200 rounded-md focus:outline-none bg-gray-100" - /> -
+
+ +

+ If you don't set a budget, we will aim to minimise cost + anyway +

+ handleBudgeChange(e)} + className="p-2 border border-gray-200 rounded-md focus:outline-none bg-gray-100" + /> +
-
- - -
+
+ + + setFundingScheme(option.value) + } + /> +
-
- - - {selectedGoal && ( -
- - -
- )} -
- -
-
- +
+ + setSelectedGoal(option.value)} + /> + {selectedGoal && ( +
+ + + setGoalValue(option.value) + } + />
+ )} +
+ +
+
+
- +
- + /> */}