From b796464241bee7416e2af44e9599331b1ca13d3a Mon Sep 17 00:00:00 2001 From: karenvicent Date: Thu, 9 Oct 2025 18:16:25 -0400 Subject: [PATCH 1/2] select component V2 --- client/src/Components/v2/Inputs/Select.tsx | 73 ++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/client/src/Components/v2/Inputs/Select.tsx b/client/src/Components/v2/Inputs/Select.tsx index fb388b334..cb3e12fcb 100644 --- a/client/src/Components/v2/Inputs/Select.tsx +++ b/client/src/Components/v2/Inputs/Select.tsx @@ -1,6 +1,71 @@ -import Select from "@mui/material/Select"; +import { Typography, Select } from "@mui/material"; +import MenuItem from "@mui/material/MenuItem"; +import { forwardRef } from "react"; import type { SelectProps } from "@mui/material/Select"; - -export const SelectInput: React.FC = ({ ...props }) => { - return { + if (!selected) { + return ( + + {placeholder ?? ""} + + ); + } + const selectedItem = items.find((item) => item._id === selected); + const displayName = selectedItem ? selectedItem.name : placeholder; + return ( + + {displayName} + + ); + }} + {...props} + > + {items.map((item) => ( + + {item.name} + + ))} + + ); + } +); +SelectInput.displayName = "SelectInput"; From 104cf194ac52c1e456284f390892a8d48bd93699 Mon Sep 17 00:00:00 2001 From: karenvicent Date: Tue, 14 Oct 2025 12:22:20 -0400 Subject: [PATCH 2/2] fix create more specific component --- client/src/Components/v2/Inputs/Select.tsx | 125 +++++++++++---------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/client/src/Components/v2/Inputs/Select.tsx b/client/src/Components/v2/Inputs/Select.tsx index 6aa2498bf..54aacf68a 100644 --- a/client/src/Components/v2/Inputs/Select.tsx +++ b/client/src/Components/v2/Inputs/Select.tsx @@ -1,81 +1,88 @@ import { Typography, Select } from "@mui/material"; import MenuItem from "@mui/material/MenuItem"; -import { forwardRef } from "react"; import type { SelectProps } from "@mui/material/Select"; import { useTheme } from "@mui/material/styles"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; -type ItemId = string | number; + +export const SelectInput: React.FC = ({ ...props }) => { + const theme = useTheme(); + return ( + { - if (!selected) { - return ( - - {placeholder ?? ""} - - ); - } - const selectedItem = items.find((item) => item._id === selected); - const displayName = selectedItem ? selectedItem.name : placeholder; +export const SelectFromItems: React.FC = ({ + items, + placeholder, + isHidden = false, + hasError = false, + ...props +}) => { + return ( + { + if (!selected) { return ( - {displayName} + {placeholder ?? ""} ); - }} - {...props} - > - {items.map((item) => ( - item._id === selected); + const displayName = selectedItem ? selectedItem.name : placeholder; + return ( + - {item.name} - - ))} - - ); - } -); + {displayName} + + ); + }} + {...props} + > + {items.map((item) => ( + + {item.name} + + ))} + + ); +}; + SelectInput.displayName = "SelectInput"; +SelectFromItems.displayName = "SelectFromItems";