From 04280351ab31fdf0c02130c55e64a18a6389c240 Mon Sep 17 00:00:00 2001 From: Clement Mwimo Date: Thu, 16 Jul 2026 17:56:54 -0600 Subject: [PATCH 1/2] feat: use MXUI Select component for property type manual account --- src/components/Select.tsx | 73 +++++++++++++++++++ src/privacy/input.ts | 3 + src/views/manualAccount/ManualAccountForm.tsx | 7 +- 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 src/components/Select.tsx diff --git a/src/components/Select.tsx b/src/components/Select.tsx new file mode 100644 index 0000000000..da3e153de1 --- /dev/null +++ b/src/components/Select.tsx @@ -0,0 +1,73 @@ +import React from 'react' +import FormControl from '@mui/material/FormControl' +import FormHelperText from '@mui/material/FormHelperText' +import InputLabel from '@mui/material/InputLabel' +import MenuItem from '@mui/material/MenuItem' +import MuiSelect, { SelectChangeEvent } from '@mui/material/Select' + +export interface SelectOption { + label: string + value: string +} + +export interface SelectProps { + 'data-test'?: string + error?: boolean + fullWidth?: boolean + helperText?: string + label: string + name: string + onChange: (e: { target: { name: string; value: string } }) => void + options?: SelectOption[] + placeholder?: string + value: string +} + +export const Select = ({ + 'data-test': dataTest, + error, + fullWidth = true, + helperText, + label, + name, + onChange, + options = [], + placeholder = 'Select a value', + value, +}: SelectProps) => { + const handleChange = (e: SelectChangeEvent) => { + onChange({ target: { name, value: e.target.value as string } }) + } + + return ( + + {label} + { + if (selected === '') { + return placeholder + } + const option = options.find((opt) => opt.value === selected) + return option ? option.label : selected + }} + value={value} + > + + {placeholder} + + {options.map((option) => ( + + {option.label} + + ))} + + {helperText && {helperText}} + + ) +} diff --git a/src/privacy/input.ts b/src/privacy/input.ts index 687b07b5d9..6b9729046a 100644 --- a/src/privacy/input.ts +++ b/src/privacy/input.ts @@ -2,6 +2,7 @@ // This is the ONLY file that @kyper related inputs should be directly imported import { Radio, PASSWORD_VALIDATIONS } from '@kyper/input' +import { Select } from 'src/components/Select' import { SelectionBox } from '@mxenabled/mxui' import { UserFeedback } from '@kyper/userfeedback' import { withProtection } from 'src/privacy/withProtection' @@ -20,12 +21,14 @@ import { TextField } from '@mxenabled/mxui' const ProtectedTextField = withProtection(TextField) const ProtectedRadio = withProtection(Radio) +const ProtectedSelect = withProtection(Select) const ProtectedSelectionBox = withProtection(SelectionBox) const ProtectedUserFeedback = withProtection(UserFeedback) export { ProtectedTextField as TextField, ProtectedRadio as Radio, + ProtectedSelect as Select, ProtectedSelectionBox as SelectionBox, ProtectedUserFeedback as UserFeedback, PASSWORD_VALIDATIONS as PasswordValidations, diff --git a/src/views/manualAccount/ManualAccountForm.tsx b/src/views/manualAccount/ManualAccountForm.tsx index 645cc31f77..11772c2b32 100644 --- a/src/views/manualAccount/ManualAccountForm.tsx +++ b/src/views/manualAccount/ManualAccountForm.tsx @@ -309,12 +309,13 @@ export const ManualAccountForm = React.forwardRef ) + + expect(screen.getByLabelText('Account type')).toBeInTheDocument() + expect(screen.getByText('Select a value')).toBeInTheDocument() + }) + + it('calls onChange with the selected value', async () => { + const user = userEvent.setup() + const handleChange = vi.fn() + + render(