diff --git a/src/components/Chatbot/Navbar.jsx b/src/components/Chatbot/Navbar.jsx new file mode 100644 index 0000000..b4f6837 --- /dev/null +++ b/src/components/Chatbot/Navbar.jsx @@ -0,0 +1,41 @@ +// Navbar.js +import React, { useState } from "react"; +import { useNavigate } from "react-router-dom"; +import styles from "./Navbar.module.css"; + +const Navbar = ({ user }) => { + const navigate = useNavigate(); + const [showDropdown, setShowDropdown] = useState(false); + + const toggleDropdown = () => { + setShowDropdown((prev) => !prev); + }; + + return ( + + ); +}; + +export default Navbar; diff --git a/src/components/Chatbot/Navbar.module.css b/src/components/Chatbot/Navbar.module.css new file mode 100644 index 0000000..e339947 --- /dev/null +++ b/src/components/Chatbot/Navbar.module.css @@ -0,0 +1,93 @@ +/* Navbar.module.css */ + +.navbar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 15px 30px; + background-color: #333; + color: white; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + } + + .logo { + font-size: 24px; + font-weight: bold; + cursor: pointer; + color: white; + text-transform: uppercase; + } + + .nav_links { + display: flex; + list-style: none; + margin: 0; + padding: 0; + } + + .nav_links li { + margin-left: 20px; + cursor: pointer; + font-size: 16px; + transition: color 0.3s; + } + + .nav_links li:hover { + color: #4CAF50; + } + + .user_menu { + position: relative; + cursor: pointer; + } + + .user_icon { + font-size: 22px; + color: white; + } + + .dropdown_content { + position: absolute; + top: 30px; + right: 0; + background-color: #fff; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + border-radius: 8px; + padding: 10px; + z-index: 10; + } + + .dropdown_content a { + display: block; + padding: 8px 15px; + text-decoration: none; + color: #333; + font-size: 16px; + transition: background-color 0.3s; + } + + .dropdown_content a:hover { + background-color: #f1f1f1; + } + + .favourited { + color: #ff6347; + } + + @media (max-width: 768px) { + .navbar { + flex-direction: column; + align-items: flex-start; + } + + .nav_links { + flex-direction: column; + margin-top: 10px; + } + + .nav_links li { + margin-left: 0; + margin-bottom: 10px; + } + } + \ No newline at end of file diff --git a/src/components/Chatbot/Save.module.css b/src/components/Chatbot/Save.module.css index 2183ec6..ff6637b 100644 --- a/src/components/Chatbot/Save.module.css +++ b/src/components/Chatbot/Save.module.css @@ -1,11 +1,139 @@ -/* Styles for Navbar */ -.navbar_section { - position: fixed; - top: 0; +/* Page Container */ +.pageContainer { + padding: 20px; + font-family: Arial, sans-serif; +} + +/* Title */ +.title { + text-align: center; + font-size: 28px; + margin-bottom: 20px; + color: #333; +} + +/* Message Table */ +.messageTable { width: 100%; - z-index: 1000; + margin-top: 20px; +} + +/* Table Header */ +.tableHeader { + display: flex; + padding: 20px; + background-color: #f1f1f1; + border-radius: 8px; + justify-content: space-between; + margin-bottom: 10px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.columnHeader { + font-weight: bold; + width: 48%; + text-align: center; + color: #555; +} + +/* Message Row */ +.messageRow { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 10px; + padding: 15px; + background-color: #fff; + border-radius: 8px; + border: 1px solid #ddd; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + transition: transform 0.3s, box-shadow 0.3s; +} + +.messageRow:hover { + transform: translateY(-5px); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); +} + +/* Message Text */ +.messageText { + width: 48%; + padding: 10px; + background-color: #f9f9f9; + border: 1px solid #ddd; + border-radius: 4px; + transition: background-color 0.3s; +} + +.messageText:hover { + background-color: #eaeaea; +} + +/* Action Icons */ +.actionIcons { + width: 48%; + display: flex; + justify-content: center; + gap: 15px; +} + +.deleteButton, .favouriteButton { + background: none; + border: none; + font-size: 22px; + cursor: pointer; + transition: color 0.3s, transform 0.3s; +} + +.deleteButton:hover, .favouriteButton:hover { + color: #ff4d4d; + transform: scale(1.2); +} + +.favourited { + color: #ff6347; +} + +/* Buttons Container */ +.buttonsContainer { + display: flex; + justify-content: space-between; + margin-top: 30px; +} + +.backButton, .clearButton { + padding: 12px 25px; + background-color: #4CAF50; + color: white; + border-radius: 8px; + border: none; + cursor: pointer; + font-size: 16px; + transition: background-color 0.3s, transform 0.3s; +} + +.backButton:hover, .clearButton:hover { + background-color: #45a049; + transform: scale(1.05); } +.clearButton { + background-color: #f44336; +} + +.clearButton:hover { + background-color: #e53935; +} + +/* No Messages */ +.noMessages { + text-align: center; + color: #777; + font-size: 18px; + font-style: italic; +} + +/* Navbar Styles */ .navbar { height: 70px; background-color: #52a7bc; @@ -15,6 +143,10 @@ padding: 0 20px; margin: 0; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); + position: fixed; + top: 0; + width: 100%; + z-index: 1000; } .logo { @@ -23,12 +155,14 @@ cursor: pointer; } +/* Navbar Links Section */ .nav_links { list-style-type: none; display: flex; gap: 20px; } +/* Each Navbar Item */ .nav_links li { color: white; padding: 10px; @@ -41,40 +175,51 @@ color: #cfcfcf; } -/* Styles for Saved Messages */ -.title { - text-align: center; - margin: 20px 0; +/* User Menu Section */ +.user_menu { + display: flex; + align-items: center; + position: relative; + cursor: pointer; + margin-left: 20px; } -.messageTable { +/* User Icon Style (دائرة تمثل نوع المستخدم) */ +.user_icon { + width: 40px; + height: 40px; + border-radius: 50%; + background-color: #f1f1f1; display: flex; - flex-direction: column; align-items: center; + justify-content: center; + color: white; + font-size: 1.2rem; + cursor: pointer; + margin-left: 20px; } -.messageRow { +.dropdown_content { display: flex; - justify-content: space-between; - width: 80%; - padding: 10px; - border-bottom: 1px solid #ddd; + flex-direction: column; + position: absolute; + top: 50px; + right: 0; + background-color: white; + min-width: 160px; + box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2); + z-index: 1; + border-radius: 5px; } -.iconContainer { - display: flex; - gap: 10px; +.dropdown_content a { + padding: 10px; + text-decoration: none; + color: black; + border-radius: 5px; } -.backButton, .clearButton { - margin: 10px; - padding: 10px 20px; - border: none; +.dropdown_content a:hover { background-color: #52a7bc; color: white; - cursor: pointer; } - -.clearButton { - background-color: #ff4d4d; /* Red color for clear button */ -} \ No newline at end of file diff --git a/src/components/Chatbot/SavedMessages.jsx b/src/components/Chatbot/SavedMessages.jsx index f9c2aa4..5e68f66 100644 --- a/src/components/Chatbot/SavedMessages.jsx +++ b/src/components/Chatbot/SavedMessages.jsx @@ -1,93 +1,90 @@ +// SavedMessages.js import React, { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; +import Navbar from "./Navbar"; // استيراد الـ Navbar import styles from "./Save.module.css"; -import { initializeApp } from 'firebase/app'; -import { getFirestore, collection, getDocs, setDoc, doc } from 'firebase/firestore'; - -const firebaseConfig = { - apiKey: "AIzaSyDc1iS4NX2um7sqJuYRSll9Il_7V6g6LsE", - authDomain: "graduatinproject.firebaseapp.com", - projectId: "graduatinproject", - storageBucket: "graduatinproject.appspot.com", - messagingSenderId: "361149223809", - appId: "1:361149223809:web:58467e248f81422f97ce80", - measurementId: "G-NRG6TMTB8Q" -}; - -// Initialize Firebase -const app = initializeApp(firebaseConfig); -const db = getFirestore(app); const SavedMessages = () => { const navigate = useNavigate(); const [savedMessages, setSavedMessages] = useState([]); + const [user, setUser] = useState(true); // لتحديد نوع المستخدم، يمكنك تعديل هذه القيمة بحسب حالتك. + // تحميل الرسائل المحفوظة من localStorage عند تحميل الصفحة useEffect(() => { - const fetchMessages = async () => { - const messagesCollection = collection(db, "messages"); - const messageSnapshot = await getDocs(messagesCollection); - const messagesList = messageSnapshot.docs.map(doc => ({ id: doc.id, ...doc.data() })); - setSavedMessages(messagesList); - }; - - fetchMessages(); + const storedMessages = JSON.parse(localStorage.getItem("savedMessages")) || []; + setSavedMessages(storedMessages); }, []); - const handleDeleteMessage = async (id) => { - // حذف الرسالة من Firebase - await deleteDoc(doc(db, "messages", id)); - setSavedMessages(savedMessages.filter(msg => msg.id !== id)); + // حذف رسالة محفوظة + const handleDeleteMessage = (index) => { + const updatedMessages = savedMessages.filter((_, i) => i !== index); + setSavedMessages(updatedMessages); + localStorage.setItem("savedMessages", JSON.stringify(updatedMessages)); + }; + + // إضافة رسالة للمفضلة + const handleFavouriteMessage = (index) => { + const updatedMessages = [...savedMessages]; + updatedMessages[index].favourite = !updatedMessages[index].favourite; + setSavedMessages(updatedMessages); + localStorage.setItem("savedMessages", JSON.stringify(updatedMessages)); }; - const handleClearAllMessages = async () => { - for (const msg of savedMessages) { - await deleteDoc(doc(db, "messages", msg.id)); - } + // مسح كل الرسائل المحفوظة + const handleClearAllMessages = () => { setSavedMessages([]); + localStorage.removeItem("savedMessages"); }; return ( -
{msg.text}
-No saved messages yet.
)} -