From ab17c2bb926dc141cf09474ab3da8ce41a51e468 Mon Sep 17 00:00:00 2001 From: dimitar Date: Thu, 3 Apr 2025 01:27:07 +0200 Subject: [PATCH] translation, form fix --- .../src/components/adminPanel/AdminPanel.jsx | 181 ++++++++++-------- .../src/components/dashboard/Dashboard.jsx | 70 ++++--- .../src/components/documentUpload/Clients.jsx | 0 .../documentUpload/DocumentUpload.jsx | 32 ++-- .../src/components/documentUpload/Users.jsx | 0 5 files changed, 161 insertions(+), 122 deletions(-) create mode 100644 frontend/src/components/documentUpload/Clients.jsx create mode 100644 frontend/src/components/documentUpload/Users.jsx diff --git a/frontend/src/components/adminPanel/AdminPanel.jsx b/frontend/src/components/adminPanel/AdminPanel.jsx index a90f68a..ba6c5d3 100644 --- a/frontend/src/components/adminPanel/AdminPanel.jsx +++ b/frontend/src/components/adminPanel/AdminPanel.jsx @@ -8,6 +8,7 @@ import { } from "../../services/api"; import DocumentUpload from "../documentUpload/DocumentUpload"; import { useNavigate } from "react-router-dom"; +import { motion } from "framer-motion"; import { FiUsers, FiFile, @@ -16,8 +17,10 @@ import { FiLoader, FiKey, } from "react-icons/fi"; +import { useRef } from "react"; function AdminPanel() { + const createUserFormRef = useRef(null); const navigate = useNavigate(); const [activeTab, setActiveTab] = useState("documents"); const [users, setUsers] = useState([]); @@ -87,15 +90,17 @@ function AdminPanel() { e.preventDefault(); try { await createUser(newUser); + fetchData(); + } catch (err) { + setError("Failed to create user"); + } finally { + // setNewUser(initialUserFormState); setNewUser({ name: "", email: "", password: "", isAdmin: false, }); - fetchData(); - } catch (err) { - setError("Failed to create user"); } }; @@ -123,9 +128,9 @@ function AdminPanel() { if (!isAdmin) return null; const tabs = [ - { id: "documents", name: "Documents", icon: FiFile }, - { id: "users", name: "Users", icon: FiUsers }, - { id: "upload", name: "Upload Document", icon: FiUpload }, + { id: "documents", name: "Документи", icon: FiFile }, + { id: "users", name: "Клиенти", icon: FiUsers }, + { id: "upload", name: "Прикачи документ", icon: FiUpload }, ]; if (loading) { @@ -146,9 +151,13 @@ function AdminPanel() {

Admin Dashboard

-

Manage users and documents

+

Клиенти и доументи

- + {/* */} {/* Tabs */}
{tabs.map(({ id, name, icon: Icon }) => ( @@ -180,12 +189,15 @@ function AdminPanel() {

- Reset Password for {resetPasswordModal.userName} + Ресетирај лозинка за корисникот +

+

+ {resetPasswordModal.userName}

setResetPasswordModal({ @@ -212,7 +224,7 @@ function AdminPanel() { } className="px-4 py-2 text-neutral-400 hover:text-white transition-colors" > - Cancel + Откажи
@@ -232,35 +244,40 @@ function AdminPanel() {
{activeTab === "documents" && (
-
- - - - - - - - - - - - {documents.map((doc) => ( - - - */} + + + + + ))} + +
- Title - - Status - - Uploaded By - - Shared With - - Created At -
{doc.title} + +
+ + + + + {/* */} + + + + + + + {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()} -
-
+
+ {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()} +
+
+
)} @@ -305,27 +323,32 @@ function AdminPanel() { <>

- Create New User + Креирај корисник

setNewUser({ ...newUser, name: e.target.value }) } className="bg-primary-700/30 border border-primary-600 rounded-lg px-4 py-2 text-white placeholder-neutral-400 focus:outline-none focus:border-primary-500 focus:ring-1 focus:ring-primary-500" - required /> setNewUser({ ...newUser, email: e.target.value }) @@ -336,8 +359,10 @@ function AdminPanel() { required /> setNewUser({ ...newUser, password: e.target.value }) @@ -359,7 +384,7 @@ function AdminPanel() { focus:ring-primary-500" />
@@ -379,16 +404,16 @@ function AdminPanel() { - Name + Име - Email + Мејл - Role + Улога - Actions + Ресетирај @@ -421,7 +446,7 @@ function AdminPanel() { className="flex items-center space-x-1 text-neutral-400 hover:text-white transition-colors" > - Reset Password + Ресетирај лозинка diff --git a/frontend/src/components/dashboard/Dashboard.jsx b/frontend/src/components/dashboard/Dashboard.jsx index 815ccf1..5b19997 100644 --- a/frontend/src/components/dashboard/Dashboard.jsx +++ b/frontend/src/components/dashboard/Dashboard.jsx @@ -1,29 +1,35 @@ -import { useState, useEffect } from 'react'; -import { useAuth } from '../../hooks/useAuth'; -import { getSharedDocuments } from '../../services/api'; -import { format } from 'date-fns'; -import { FiFolder, FiFile, FiDownload, FiChevronRight, FiLoader } from 'react-icons/fi'; -import { downloadDocument } from '../../services/api'; +import { useState, useEffect } from "react"; +import { useAuth } from "../../hooks/useAuth"; +import { getSharedDocuments } from "../../services/api"; +import { format } from "date-fns"; +import { + FiFolder, + FiFile, + FiDownload, + FiChevronRight, + FiLoader, +} from "react-icons/fi"; +import { downloadDocument } from "../../services/api"; function Dashboard() { const [documents, setDocuments] = useState({}); const [expandedFolders, setExpandedFolders] = useState({}); const [loading, setLoading] = useState(true); - const [error, setError] = useState(''); + const [error, setError] = useState(""); const { user } = useAuth(); useEffect(() => { const fetchDocuments = async () => { try { if (!user?.id) return; - + const response = await getSharedDocuments(user.id); // Group the documents by company and date const groupedDocs = groupDocumentsByCompanyAndDate(response.data); setDocuments(groupedDocs); } catch (err) { - console.error('Error fetching documents:', err); - setError('Failed to fetch documents'); + console.error("Error fetching documents:", err); + setError("Failed to fetch documents"); } finally { setLoading(false); } @@ -34,12 +40,12 @@ function Dashboard() { const groupDocumentsByCompanyAndDate = (docs) => { if (!Array.isArray(docs)) { - console.error('Expected array of documents, received:', docs); + console.error("Expected array of documents, received:", docs); return {}; } return docs.reduce((acc, doc) => { - const folderName = `${doc.sharedWith?.name || 'Unknown'}-${format(new Date(doc.createdAt), 'yyyy-MM-dd')}`; + const folderName = `${doc.sharedWith?.name || user.name}-${format(new Date(doc.createdAt), "dd-MM-yyyy")}`; if (!acc[folderName]) { acc[folderName] = []; } @@ -52,15 +58,15 @@ function Dashboard() { try { await downloadDocument(s3Key); } catch (err) { - console.error('Error downloading document:', err); - alert('Failed to download document. Please try again.'); + console.error("Error downloading document:", err); + alert("Failed to download document. Please try again."); } }; const toggleFolder = (folderName) => { - setExpandedFolders(prev => ({ + setExpandedFolders((prev) => ({ ...prev, - [folderName]: !prev[folderName] + [folderName]: !prev[folderName], })); }; @@ -69,7 +75,7 @@ function Dashboard() {
- Loading documents... + Се вчитува...
); @@ -89,8 +95,12 @@ function Dashboard() {
-

Your Documents

-

Access and manage your shared documents

+

+ Вашите Документи +

+

+ {/* Access and manage your shared documents */} +

@@ -98,22 +108,24 @@ function Dashboard() { Object.entries(documents).map(([folderName, docs]) => (
@@ -123,7 +135,7 @@ function Dashboard() { {docs.map((doc) => (
@@ -132,7 +144,7 @@ function Dashboard() {
)) ) : ( -
+

No documents available

)} @@ -156,4 +170,4 @@ function Dashboard() { ); } -export default Dashboard; \ No newline at end of file +export default Dashboard; diff --git a/frontend/src/components/documentUpload/Clients.jsx b/frontend/src/components/documentUpload/Clients.jsx new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/components/documentUpload/DocumentUpload.jsx b/frontend/src/components/documentUpload/DocumentUpload.jsx index 975237f..d89b7b9 100644 --- a/frontend/src/components/documentUpload/DocumentUpload.jsx +++ b/frontend/src/components/documentUpload/DocumentUpload.jsx @@ -64,12 +64,12 @@ function DocumentUpload() { formData.append("uploadedById", uploadedById); // Debug log - console.log("Form Data:", { - title, - sharedWithId, - uploadedById, - fileName: file.name, - }); + // console.log("Form Data:", { + // title, + // sharedWithId, + // uploadedById, + // fileName: file.name, + // }); try { await uploadDocument(formData); @@ -90,9 +90,9 @@ function DocumentUpload() {

- Upload Document + Сподели документ

-

Share documents with your clients

+ {/*

Share documents with your clients

*/}
{/* Title Input */}
-