From bddbbc3ee0cc0630d6d823f01647ab63e18b9e71 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 6 Dec 2025 02:01:27 -0500 Subject: [PATCH 1/2] updates --- .../Admin/B2BMessages/B2BMessages.tsx | 235 +++++++++++++++--- 1 file changed, 200 insertions(+), 35 deletions(-) diff --git a/client/src/containers/Admin/B2BMessages/B2BMessages.tsx b/client/src/containers/Admin/B2BMessages/B2BMessages.tsx index 5e39e4c..6503725 100644 --- a/client/src/containers/Admin/B2BMessages/B2BMessages.tsx +++ b/client/src/containers/Admin/B2BMessages/B2BMessages.tsx @@ -77,9 +77,105 @@ // export default B2BMessages; +// import React, { useEffect, useState } from "react"; +// import axios from "axios"; + +// type Message = { +// updatedAt: string; +// createdAt: string; +// sender: string; +// receiver: string; +// content: string; +// }; + +// const B2BMessages: React.FC = () => { +// const [messages, setMessages] = useState([]); +// const [loading, setLoading] = useState(true); +// const [error, setError] = useState(null); + +// useEffect(() => { +// const fetchMessages = async () => { +// try { +// const res = await axios.get("/api/message/cheat"); +// setMessages(res.data); +// setError(null); +// } catch (err) { +// console.error("Error fetching messages:", err); +// setError("Failed to fetch messages. Please try again later."); +// } finally { +// setLoading(false); +// } +// }; + +// fetchMessages(); +// }, []); + +// const formatDate = (dateStr: string) => { +// const d = new Date(dateStr); +// return d.toLocaleString(); +// }; + +// return ( +//
+//

Admin Dashboard

+ +// {/* Loading Indicator */} +// {loading && ( +//

+// Loading +// messages… +//

+// )} + +// {/* Error Message */} +// {error &&

{error}

} + +// {/* No Messages */} +// {!loading && !error && messages.length === 0 && ( +//

No messages found.

+// )} + +// {/* Message Table */} +// {!loading && messages.length > 0 && ( +// +// +// +// +// +// +// +// +// +// +// +// {messages.map((msg, i) => ( +// +// +// +// +// +// +// +// ))} +// +//
SenderReceiverContentCreatedUpdated
{msg.sender}{msg.receiver}{msg.content}{formatDate(msg.createdAt)}{formatDate(msg.updatedAt)}
+// )} +//
+// ); +// }; + +// const cellStyle = { +// border: "1px solid #ddd", +// padding: "8px", +// fontSize: "14px", +// }; + +// export default B2BMessages; + import React, { useEffect, useState } from "react"; import axios from "axios"; +// Define the message type type Message = { updatedAt: string; createdAt: string; @@ -116,58 +212,127 @@ const B2BMessages: React.FC = () => { }; return ( -
-

Admin Dashboard

+
+

Admin B2B Messages

- {/* Loading Indicator */} + {/* Loading State */} {loading && ( -

- Loading - messages… -

+
+
+ Loading messages... +
)} {/* Error Message */} - {error &&

{error}

} + {error &&
{error}
} {/* No Messages */} {!loading && !error && messages.length === 0 && ( -

No messages found.

+
No messages found.
)} - {/* Message Table */} + {/* Messages Table */} {!loading && messages.length > 0 && ( - - - - - - - - - - - - {messages.map((msg, i) => ( - - - - - - +
+
SenderReceiverContentCreatedUpdated
{msg.sender}{msg.receiver}{msg.content}{formatDate(msg.createdAt)}{formatDate(msg.updatedAt)}
+ + + + + + + - ))} - -
SenderReceiverContentCreatedUpdated
+ + + {messages.map((msg, i) => ( + + {msg.sender} + {msg.receiver} + {msg.content} + {formatDate(msg.createdAt)} + {formatDate(msg.updatedAt)} + + ))} + + +
)}
); }; -const cellStyle = { - border: "1px solid #ddd", - padding: "8px", - fontSize: "14px", +// Styles +const styles: { [key: string]: React.CSSProperties } = { + container: { + padding: "20px", + fontFamily: "'Segoe UI', Tahoma, Geneva, Verdana, sans-serif", + maxWidth: "1200px", + margin: "0 auto", + }, + header: { + marginBottom: "20px", + fontSize: "2rem", + fontWeight: "bold", + color: "#333", + }, + loadingContainer: { + display: "flex", + alignItems: "center", + fontSize: "1.1rem", + fontWeight: 500, + color: "#555", + }, + error: { + color: "red", + fontWeight: "bold", + marginBottom: "10px", + }, + noMessages: { + fontStyle: "italic", + color: "#777", + marginTop: "10px", + }, + tableContainer: { + maxHeight: "500px", + overflowY: "auto", + border: "1px solid #ddd", + borderRadius: "8px", + }, + table: { + width: "100%", + borderCollapse: "collapse", + minWidth: "800px", + }, + tableHeaderRow: { + position: "sticky", + top: 0, + backgroundColor: "#007BFF", + color: "#fff", + zIndex: 1, + }, + tableHeader: { + padding: "12px", + textAlign: "left", + fontWeight: "bold", + borderBottom: "2px solid #0056b3", + }, + tableRow: { + transition: "background-color 0.2s", + cursor: "default", + }, + tableCell: { + padding: "10px", + borderBottom: "1px solid #ddd", + fontSize: "0.95rem", + wordBreak: "break-word", + }, }; export default B2BMessages; From 964ff588d74a9431fc18bca20be4dbd68ae09605 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 6 Dec 2025 02:05:54 -0500 Subject: [PATCH 2/2] updates --- .../Admin/Users/UserProfile/UserProfile.tsx | 527 ++++++------------ 1 file changed, 160 insertions(+), 367 deletions(-) diff --git a/client/src/containers/Admin/Users/UserProfile/UserProfile.tsx b/client/src/containers/Admin/Users/UserProfile/UserProfile.tsx index aaf3fe6..d0503f6 100644 --- a/client/src/containers/Admin/Users/UserProfile/UserProfile.tsx +++ b/client/src/containers/Admin/Users/UserProfile/UserProfile.tsx @@ -229,413 +229,206 @@ // export default UserProfile; -// import React, { useEffect, useState } from "react"; -// import { useParams, useNavigate, Link } from "react-router-dom"; -// import axios from "axios"; -// import Button from "react-bootstrap/Button"; - -// interface User { -// email: string; -// password?: string; -// description?: string; -// } - -// const UserProfile: React.FC = () => { -// const { id } = useParams<{ id: string }>(); -// const navigate = useNavigate(); -// const [user, setUser] = useState({ email: "", password: "", description: "" }); -// const [loading, setLoading] = useState(true); -// const [error, setError] = useState(null); -// const [success, setSuccess] = useState(false); - -// // Fetch user by ID -// const fetchUser = async () => { -// try { -// const { data } = await axios.get(`/api/user/${id}`); -// setUser(data); -// } catch (err) { -// setError("Failed to fetch user."); -// console.error(err); -// } finally { -// setLoading(false); -// } -// }; - -// useEffect(() => { -// fetchUser(); -// }, [id]); - -// // Handle input changes -// const handleChange = (e: React.ChangeEvent) => { -// const { name, value } = e.target; -// setUser((prev) => ({ ...prev, [name]: value })); -// }; - -// // Handle form submit -// const handleSubmit = async (e: React.FormEvent) => { -// e.preventDefault(); -// try { -// await axios.put(`/api/user/update/${id}`, { -// email: user.email, -// password: user.password, -// description: user.description, -// }); -// setSuccess(true); -// setTimeout(() => navigate("/AllUsers"), 1000); -// } catch (err) { -// setError("Failed to update user."); -// console.error(err); -// } -// }; - -// if (loading) return

Loading user data...

; - -// return ( -//
-//

Update User

-// {error &&

{error}

} -// {success &&

User updated successfully!

} - -//
-//
-// -// -//
- -//
-// -// -//
- -//
-// -//