From 619435ca57e9ea3c083c19070b65576d3aff7e42 Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Thu, 5 Sep 2024 14:38:21 +0530 Subject: [PATCH] Fix dropdown not showing selected value in SelectTeamToChat component --- .../client/components/SelectTeamToChat.tsx | 22 +-- .../client/components/form/SelectInput.tsx | 149 ------------------ 2 files changed, 13 insertions(+), 158 deletions(-) delete mode 100644 app/src/client/components/form/SelectInput.tsx diff --git a/app/src/client/components/SelectTeamToChat.tsx b/app/src/client/components/SelectTeamToChat.tsx index aaebf9f7..67e0cc21 100644 --- a/app/src/client/components/SelectTeamToChat.tsx +++ b/app/src/client/components/SelectTeamToChat.tsx @@ -1,10 +1,10 @@ import { useState, useEffect, useRef } from 'react'; import { useHistory } from 'react-router-dom'; +import Select from 'react-select'; import { type Chat } from 'wasp/entities'; import { SelectedModelSchema } from '../interfaces/BuildPageInterfaces'; import { CreateNewChatProps } from '../interfaces/PlaygroundPageInterface'; import NotificationBox from './NotificationBox'; -import { SelectInput } from './form/SelectInput'; import TextareaAutosize from 'react-textarea-autosize'; import { createNewChat } from 'wasp/client/operations'; @@ -18,8 +18,8 @@ const SelectTeamToChat = ({ userTeams }: any) => { const [isSubmitting, setIsSubmitting] = useState(false); const isRedirecting = useRef(false); - const handleTeamChange = (value: string) => { - setTeam(value); + const handleTeamChange = (selectedOption: { value: string; label: string } | null) => { + setTeam(selectedOption ? selectedOption.value : ''); }; const handleMessageChange = (event: React.ChangeEvent) => { @@ -70,7 +70,12 @@ const SelectTeamToChat = ({ userTeams }: any) => { setNotificationErrorMessage(null); }; - const options = allTeams ? allTeams.map((team: SelectedModelSchema) => team.json_str.name) : []; + const options = allTeams + ? allTeams.map((team: SelectedModelSchema) => ({ + value: team.json_str.name, + label: team.json_str.name, + })) + : []; return (
@@ -81,14 +86,13 @@ const SelectTeamToChat = ({ userTeams }: any) => { - {}} - isRequired={true} + className='pt-1 pb-1' + value={options.find((option) => option.value === team) || null} + isSearchable={true} /> {formError.team &&
{formError.team}
}