From 03d0ff2ca41f2e9ad8c0ae606b1136860fedbc9c Mon Sep 17 00:00:00 2001
From: ItzCrazyKns <95534749+ItzCrazyKns@users.noreply.github.com>
Date: Tue, 29 Oct 2024 19:59:58 +0530
Subject: [PATCH] feat(navbar): make delete & plus button work
---
ui/components/ChatWindow.tsx | 2 +-
ui/components/DeleteChat.tsx | 9 +++++++++
ui/components/Navbar.tsx | 24 +++++++++++++++++-------
3 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/ui/components/ChatWindow.tsx b/ui/components/ChatWindow.tsx
index 986f8ae..7b2ce88 100644
--- a/ui/components/ChatWindow.tsx
+++ b/ui/components/ChatWindow.tsx
@@ -503,7 +503,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
{messages.length > 0 ? (
<>
-
+
void;
+ redirect?: boolean;
}) => {
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
const [loading, setLoading] = useState(false);
+ const router = useRouter();
+
const handleDelete = async () => {
setLoading(true);
try {
@@ -44,6 +49,10 @@ const DeleteChat = ({
const newChats = chats.filter((chat) => chat.id !== chatId);
setChats(newChats);
+
+ if (redirect) {
+ router.push('/');
+ }
} catch (err: any) {
toast.error(err.message);
} finally {
diff --git a/ui/components/Navbar.tsx b/ui/components/Navbar.tsx
index 020dfb4..ca57a8b 100644
--- a/ui/components/Navbar.tsx
+++ b/ui/components/Navbar.tsx
@@ -2,8 +2,15 @@ import { Clock, Edit, Share, Trash } from 'lucide-react';
import { Message } from './ChatWindow';
import { useEffect, useState } from 'react';
import { formatTimeDifference } from '@/lib/utils';
+import DeleteChat from './DeleteChat';
-const Navbar = ({ messages }: { messages: Message[] }) => {
+const Navbar = ({
+ chatId,
+ messages,
+}: {
+ messages: Message[];
+ chatId: string;
+}) => {
const [title, setTitle] = useState('');
const [timeAgo, setTimeAgo] = useState('');
@@ -39,10 +46,12 @@ const Navbar = ({ messages }: { messages: Message[] }) => {
return (
-
+ >
+
+
{timeAgo} ago
@@ -54,10 +63,11 @@ const Navbar = ({ messages }: { messages: Message[] }) => {
size={17}
className="active:scale-95 transition duration-100 cursor-pointer"
/>
-
+ className='text-red-400 active:scale-95 transition duration-100 cursor-pointer'
+ /> */}
+
{}} />
);