diff --git a/src/components/DynamicForm.tsx b/src/components/DynamicForm.tsx index 5d4cfec1..0850fe48 100644 --- a/src/components/DynamicForm.tsx +++ b/src/components/DynamicForm.tsx @@ -5,6 +5,7 @@ import { Theme as MaterialUITheme } from '@rjsf/mui'; import { withTheme } from '@rjsf/core'; import MultiSelectCheckboxes from './MultiSelectCheckboxes'; import CustomRadioWidget from './CustomRadioWidget'; +import MultiSelectDropdown from './MultiSelectDropdown'; import { RJSFSchema, RegistryFieldsType, WidgetProps } from '@rjsf/utils'; import { useTranslation } from 'next-i18next'; import { Button, Divider } from '@mui/material'; @@ -44,6 +45,7 @@ const DynamicForm: React.FC = ({ const widgets = { MultiSelectCheckboxes: MultiSelectCheckboxes, CustomRadioWidget: CustomRadioWidget, + MultiSelectDropdown: MultiSelectDropdown, }; const { t } = useTranslation(); diff --git a/src/components/GeneratedSchemas.ts b/src/components/GeneratedSchemas.ts index 04c49791..3339c6c0 100644 --- a/src/components/GeneratedSchemas.ts +++ b/src/components/GeneratedSchemas.ts @@ -149,7 +149,7 @@ export const GenerateSchemaAndUiSchema = ( if (maxSelections) { fieldSchema.maxItems = maxSelections; } - fieldUiSchema['ui:widget'] = 'select'; + fieldUiSchema['ui:widget'] = 'MultiSelectDropdown'; } if (!isMultiSelect && type === 'drop_down') { diff --git a/src/components/ManageUser.tsx b/src/components/ManageUser.tsx index d0a6729d..17386c40 100644 --- a/src/components/ManageUser.tsx +++ b/src/components/ManageUser.tsx @@ -460,6 +460,7 @@ const manageUsers: React.FC = ({ setOpenFacilitatorModal(false); }; + const handleDeleteUser = () => {}; return ( <> {/*
*/} @@ -776,6 +777,7 @@ const manageUsers: React.FC = ({ userId={userId} open={openDeleteUserModal} onClose={handleCloseModal} + onUserDelete={handleDeleteUser} /> = ({ + options, + value, + required, + disabled, + readonly, + onChange, + schema, +}) => { + const handleChange = (event: any) => { + onChange(event.target.value); + }; + + const isEnumArray = (items: any): items is { enum: any[] } => { + return items && Array.isArray(items.enum); + }; + + const selectOptions = isEnumArray(schema?.items) + ? schema.items.enum.map((val, index) => ({ + value: val, + label: schema.enumNames ? schema.enumNames[index] : val, + })) + : []; + + return ( + + (selected as string[]) + .map( + (val) => + selectOptions?.find((opt: any) => opt.value === val)?.label + ) + .join(', '), + }} + InputLabelProps={{ required: required }} + fullWidth + disabled={disabled || readonly} + > + {selectOptions?.map((option: any) => ( + + + + ))} + + ); +}; + +export default MultiSelectDropdown;