diff --git a/src/app/index.jsx b/src/app/index.jsx index 86327c4..443de48 100644 --- a/src/app/index.jsx +++ b/src/app/index.jsx @@ -1,5 +1,5 @@ import React from "react"; -import ChatLayout from "src/components/ui/ChatLayout"; +import ChatLayout from "../components/ui/ChatLayout"; function App() { return ( diff --git a/src/components/ui/Button/ActionButton.css b/src/components/ui/Button/ActionButton.css new file mode 100644 index 0000000..499ef30 --- /dev/null +++ b/src/components/ui/Button/ActionButton.css @@ -0,0 +1,29 @@ +.action-btn { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 6px 12px; + border: 2px solid var(--btn-color); + border-radius: 6px; + background-color: white; + color: var(--btn-color); + font-weight: 500; + cursor: pointer; + transition: all 0.25s ease; +} + +.action-btn:hover, +.action-btn:focus { + background-color: var(--btn-color); + color: white; + border-color: var(--btn-color); +} + +.action-btn svg { + fill: currentColor; + transition: fill 0.25s ease; +} + +.action-btn:hover { + transform: translateY(-1px); +} diff --git a/src/components/ui/Button/ActionButton.jsx b/src/components/ui/Button/ActionButton.jsx new file mode 100644 index 0000000..a14b1fe --- /dev/null +++ b/src/components/ui/Button/ActionButton.jsx @@ -0,0 +1,57 @@ +import './ActionButton.css'; + +export default function ActionButton({ + onClick, + children, + type = 'add', // 'add' or 'delete' + ...props +}) { + // Define color and icon based on type + const config = { + add: { + color: '#0F2862', + svg: ( + + + + ), + }, + delete: { + color: '#9E363A', + svg: ( + + + + ), + }, + }; + + const { color, svg } = config[type] || config.add; + + return ( + + ); +} diff --git a/src/components/ui/Button/DeleteButton.jsx b/src/components/ui/Button/DeleteButton.jsx deleted file mode 100644 index 9df06da..0000000 --- a/src/components/ui/Button/DeleteButton.jsx +++ /dev/null @@ -1,19 +0,0 @@ -import Button from 'react-bootstrap/Button'; - -export default function DeleteButton({ onClick, variant = "outline-danger", children, ...props }) { - return ( - - ); -} diff --git a/src/components/ui/Button/NewChatButton.css b/src/components/ui/Button/NewChatButton.css deleted file mode 100644 index 7217f58..0000000 --- a/src/components/ui/Button/NewChatButton.css +++ /dev/null @@ -1,13 +0,0 @@ -.custom-btn { - background-color: white !important; - border: 2px solid #0F2862 !important; - color: #0F2862 !important; - transition: all 0.25s ease; -} - -.custom-btn:hover, -.custom-btn:focus { - background-color: #0F2862 !important; - color: white !important; - border-color: #0F2862 !important; -} diff --git a/src/components/ui/Button/NewChatButton.jsx b/src/components/ui/Button/NewChatButton.jsx deleted file mode 100644 index 3ff7052..0000000 --- a/src/components/ui/Button/NewChatButton.jsx +++ /dev/null @@ -1,19 +0,0 @@ -import Button from 'react-bootstrap/Button'; -import './NewChatButton.css' -export default function NewChatButton({ onClick, variant = "outline-light", children, ...props }) { - return ( - - ); -} diff --git a/src/components/ui/ChatHeader.jsx b/src/components/ui/ChatHeader.jsx index 13f5c83..603cb61 100644 --- a/src/components/ui/ChatHeader.jsx +++ b/src/components/ui/ChatHeader.jsx @@ -1,6 +1,24 @@ import React from "react"; +import ActionButton from "./Button/ActionButton.jsx"; export default function ChatHeader({ title = "AI Assistant" }) { + // Delete chat log (frontend + backend) + const handleDeleteChat = async () => { + if (!window.confirm("Delete all messages?")) return; + await fetch(`/api/chat/${conversationId}`, { method: "DELETE" }); + setMessages([]); + }; + + // Restart chat (new conversation) + const handleNewChat = async () => { + const res = await fetch("/api/chat/new", { method: "POST" }); + const data = await res.json(); + if (data.success) { + setConversationId(data.conversationId); + setMessages([]); + } + }; + return (
@@ -13,7 +31,10 @@ export default function ChatHeader({ title = "AI Assistant" }) { Ask anything — AI is listening

+ + +
); } diff --git a/src/components/ui/ChatWindow.jsx b/src/components/ui/ChatWindow.jsx index 9f35aba..7e8af82 100644 --- a/src/components/ui/ChatWindow.jsx +++ b/src/components/ui/ChatWindow.jsx @@ -1,5 +1,6 @@ -import React from "react"; -import { useRef } from "react"; +import React, { useRef, useEffect } from "react"; + + function MessageBubble({ message }) { const isUser = message.role === "user"; return (