From 5cec657af0cf95812c0669cfc35c3a3c9c40cf9e Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Tue, 1 Feb 2022 17:30:41 -0800 Subject: [PATCH] right to the stage of creating a conversation with anyone in the world --- .../CreateConversation.tsx.tsx | 61 ++++++++++++++----- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/packages/web/components/FullPageExperiences/CreateConversation.tsx.tsx b/packages/web/components/FullPageExperiences/CreateConversation.tsx.tsx index 24d3d7f..f57d2fa 100644 --- a/packages/web/components/FullPageExperiences/CreateConversation.tsx.tsx +++ b/packages/web/components/FullPageExperiences/CreateConversation.tsx.tsx @@ -16,6 +16,7 @@ export default function CreateConversation() { const [selectedUsers, setSelectedUsers] = useState([] as User[]); const [isLoading, setIsLoading] = useState(false); const [userSearchInput, setUserSearchInput] = useState(""); + const [conversationName, setConversationName] = useState(""); // recommendations list: algolio results + cached "relevant users" from all cached conversations currently // options for the select @@ -29,10 +30,6 @@ export default function CreateConversation() { input.current?.focus(); }, []); - // as people are selected, add a list of users - // if it's an email of a non-nirvana user, then hit invite button to email them with a voice clip along with it - // if it's an existing user, then show a nice chip of that user's profile picture and their name - const handleChangeUserSearchInput = async (event) => { const newInput = event?.target?.value; console.log("searching for : " + newInput); @@ -86,6 +83,12 @@ export default function CreateConversation() { toast("Already added member!"); return; } + + // also remove from the search set + // for now unless they re-search, they will see it again but for now not an issue + setRecommendedUsers((prevRecUsers) => + prevRecUsers.filter((pU) => pU.id != addUser.id) + ); setSelectedUsers((prevUsers) => [addUser, ...prevUsers]); }; @@ -99,6 +102,31 @@ export default function CreateConversation() { setSelectedUsers([] as User[]); }; + const [isSubmitting, setIsSubmitting] = useState(false); + + const createConversation = (e) => { + e.preventDefault(); + setIsSubmitting(true); + + if (!conversationName) { + toast.error("Please put in a conversation name"); + return; + } + + if (!selectedUsers?.length) { + toast.error("You must select members!"); + return; + } + + try { + console.log("created conversation in database"); + } catch (error) { + toast.error("Problem in creating issue"); + } + + // setIsSubmitting(false); + }; + return (
{/* setConversationName(e.target.value)} /> - + disabled={isSubmitting} + > + Create + + )} ) : ( <>