From 4aeeaf185c5034ea0bfe153efbf42954732c5d18 Mon Sep 17 00:00:00 2001 From: Niharika Goulikar Date: Tue, 15 Oct 2024 16:43:00 +0000 Subject: [PATCH] Made ui/ux changes --- frontend/src/Navigation.tsx | 75 ++++++++++++++-------- frontend/src/assets/openNewChat.svg | 4 ++ frontend/src/conversation/Conversation.tsx | 67 ++++++++++++++----- 3 files changed, 103 insertions(+), 43 deletions(-) create mode 100644 frontend/src/assets/openNewChat.svg diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index 052a9643..4e7ec094 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -6,6 +6,7 @@ import { NavLink, useNavigate } from 'react-router-dom'; import conversationService from './api/services/conversationService'; import userService from './api/services/userService'; import Add from './assets/add.svg'; +import openNewChat from './assets/openNewChat.svg'; import DocsGPT3 from './assets/cute_docsgpt3.svg'; import Discord from './assets/discord.svg'; import Expand from './assets/expand.svg'; @@ -164,7 +165,12 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { }), ); }; - + const newChat = () => { + if (conversations && conversations?.length > 0) { + resetConversation(); + navigate('/'); + } + }; async function updateConversationName(updatedConversation: { name: string; id: string; @@ -200,26 +206,40 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { return ( <> {!navOpen && ( - +
+
+ + open new chat icon { + newChat(); + }} + /> +
+ DocsGPT +
+
+
)}
- +
+ +
DocsGPT
+
+ + + diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index fb819922..92ae0a4a 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -1,7 +1,7 @@ import { Fragment, useEffect, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; - +import newChatIcon from '../assets/openNewChat.svg'; import ArrowDown from '../assets/arrow-down.svg'; import Send from '../assets/send.svg'; import SendDark from '../assets/send_dark.svg'; @@ -9,9 +9,11 @@ import ShareIcon from '../assets/share.svg'; import SpinnerDark from '../assets/spinner-dark.svg'; import Spinner from '../assets/spinner.svg'; import RetryIcon from '../components/RetryIcon'; +import { useNavigate } from 'react-router-dom'; import Hero from '../Hero'; import { useDarkTheme, useMediaQuery } from '../hooks'; import { ShareConversationModal } from '../modals/ShareConversationModal'; +import { setConversation, updateConversationId } from './conversationSlice'; import { selectConversationId } from '../preferences/preferenceSlice'; import { AppDispatch } from '../store'; import ConversationBubble from './ConversationBubble'; @@ -27,6 +29,7 @@ import { export default function Conversation() { const queries = useSelector(selectQueries); + const navigate = useNavigate(); const status = useSelector(selectStatus); const conversationId = useSelector(selectConversationId); const dispatch = useDispatch(); @@ -120,6 +123,18 @@ export default function Conversation() { handleInput(); } }; + const resetConversation = () => { + dispatch(setConversation([])); + dispatch( + updateConversationId({ + query: { conversationId: null }, + }), + ); + }; + const newChat = () => { + resetConversation(); + navigate('/'); + }; const prepResponseView = (query: Query, index: number) => { let responseView; @@ -197,23 +212,41 @@ export default function Conversation() { }; }, []); return ( -
+
{conversationId && ( - <> +
{' '} - +
+ {isMobile && ( + + )} + + +
{isShareModalOpen && ( { @@ -222,7 +255,7 @@ export default function Conversation() { conversationId={conversationId} /> )} - +
)}