diff --git a/frontend/src/components/adminPanel/AdminPanel.jsx b/frontend/src/components/adminPanel/AdminPanel.jsx
index ba6c5d3..3b7fcd9 100644
--- a/frontend/src/components/adminPanel/AdminPanel.jsx
+++ b/frontend/src/components/adminPanel/AdminPanel.jsx
@@ -7,6 +7,7 @@ import {
resetUserPassword,
} from "../../services/api";
import DocumentUpload from "../documentUpload/DocumentUpload";
+import Documents from "../documentUpload/Documents";
import { useNavigate } from "react-router-dom";
import { motion } from "framer-motion";
import {
@@ -241,228 +242,157 @@ function AdminPanel() {
)}
-
+ {/*
*/}
+ <>
{activeTab === "documents" && (
-
-
-
-
-
-
- |
- Име
- |
- {/*
- Статус
- | */}
-
- Прикачено од
- |
-
- Споделено со
- |
-
- Креирано на
- |
-
-
-
- {documents.map((doc) => (
-
- | {doc.title} |
- {/*
-
- {doc.status}
-
- | */}
-
- {doc.uploadedBy?.name} ({doc.uploadedBy?.email})
- |
-
- {doc.sharedWith && doc.sharedWith.length > 0
- ? doc.sharedWith.map((user) => (
-
- {user.name} ({user.email})
-
- ))
- : "None"}
- |
-
- {new Date(doc.createdAt).toLocaleString()}
- |
-
- ))}
-
-
-
-
+
+
)}
-
- {activeTab === "users" && (
- <>
-
+
+
+
+
+
+ |
+ Име
+ |
+
+ Мејл
+ |
+
+ Улога
+ |
+
+ Ресетирај
+ |
+
+
+
+ {users.map((user) => (
+
+ | {user.name} |
+ {user.email} |
+
+
+ {user.isAdmin ? "Admin" : "User"}
+
+ |
+
+
+ |
+
+ ))}
+
+
+
+ >
+ )}
+
+ {activeTab === "upload" && (
+
+
+
+ )}
);
diff --git a/frontend/src/components/documentUpload/Clients.jsx b/frontend/src/components/documentUpload/Clients.jsx
deleted file mode 100644
index e69de29..0000000
diff --git a/frontend/src/components/documentUpload/Documents.jsx b/frontend/src/components/documentUpload/Documents.jsx
new file mode 100644
index 0000000..837a821
--- /dev/null
+++ b/frontend/src/components/documentUpload/Documents.jsx
@@ -0,0 +1,135 @@
+import { useState, useEffect } from "react";
+import { motion } from "framer-motion";
+import { getAllDocuments } from "../../services/api";
+import { getAllUsers } from "../../services/api";
+import {
+ FiUsers,
+ FiFile,
+ FiUpload,
+ FiKey,
+ FiLoader,
+ FiUserPlus,
+} from "react-icons/fi";
+
+function Documents() {
+ const [documents, setDocuments] = useState([]);
+ const [users, setUsers] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState("");
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ setLoading(true);
+ const [documentsResponse, usersResponse] = await Promise.all([
+ getAllDocuments(),
+ getAllUsers(),
+ ]);
+
+ // Make sure we're getting the data property from the response
+ setDocuments(
+ Array.isArray(documentsResponse.data) ? documentsResponse.data : [],
+ );
+ setUsers(Array.isArray(usersResponse.data) ? usersResponse.data : []);
+ } catch (error) {
+ console.error("Error fetching data:", error);
+ setError("Failed to load data");
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchData();
+ }, []);
+
+ if (loading) {
+ return (
+
+
+
+ );
+ }
+
+ if (error) {
+ return (
+
+ {error}
+
+ );
+ }
+
+ return (
+
+
+
+
+
+ |
+ Име
+ |
+
+ Прикачено од
+ |
+
+ Споделено со
+ |
+
+ Креирано на
+ |
+
+
+
+ {documents.length > 0 ? (
+ documents.map((doc) => (
+
+ | {doc.title || "N/A"} |
+
+ {doc.uploadedBy ? (
+ <>
+ {doc.uploadedBy.name} ({doc.uploadedBy.email})
+ >
+ ) : (
+ "N/A"
+ )}
+ |
+
+ {doc.sharedWith && doc.sharedWith.length > 0 ? (
+
+ {doc.sharedWith.map((user) => (
+
+ {user.name} ({user.email})
+
+ ))}
+
+ ) : (
+ "None"
+ )}
+ |
+
+ {doc.createdAt
+ ? new Date(doc.createdAt).toLocaleString()
+ : "N/A"}
+ |
+
+ ))
+ ) : (
+
+ |
+ No documents available
+ |
+
+ )}
+
+
+
+
+ );
+}
+
+export default Documents;
diff --git a/frontend/src/components/documentUpload/Users.jsx b/frontend/src/components/documentUpload/Users.jsx
index e69de29..f52a52e 100644
--- a/frontend/src/components/documentUpload/Users.jsx
+++ b/frontend/src/components/documentUpload/Users.jsx
@@ -0,0 +1,136 @@
+import { useState } from "react";
+
+function Users() {
+ const [newUser, setNewUser] = useState({});
+ return (
+ <>
+
+
+
+
+
+
+ |
+ Име
+ |
+
+ Мејл
+ |
+
+ Улога
+ |
+
+ Ресетирај
+ |
+
+
+
+ {users.map((user) => (
+
+ | {user.name} |
+ {user.email} |
+
+
+ {user.isAdmin ? "Admin" : "User"}
+
+ |
+
+
+ |
+
+ ))}
+
+
+
+ >
+ );
+}