From 697799b00d46a312bd49b3645496130c8fee5474 Mon Sep 17 00:00:00 2001 From: yaschalew Date: Fri, 10 Jul 2026 14:24:58 +0300 Subject: [PATCH] fix --- .../backoffice/src/pages/ActivityLogPage.tsx | 268 +++ .../backoffice/src/pages/AddSitePage.tsx | 7 + .../src/pages/AdvancedDashboardPage.tsx | 141 ++ .../backoffice/src/pages/ArchiveUsersPage.tsx | 114 + .../src/pages/ArchivedUnitsPositionsPage.tsx | 552 +++++ .../src/pages/AttachmentSignature.tsx | 230 ++ .../backoffice/src/pages/AuditLog.tsx | 264 +++ .../backoffice/src/pages/BulkUploadPage.tsx | 7 + .../src/pages/ConfigurationPage.tsx | 19 + .../src/pages/ContentManagementPage.tsx | 7 + .../backoffice/src/pages/DashboardPage.tsx | 158 ++ .../src/pages/EscalationConfigurationPage.tsx | 412 ++++ .../backoffice/src/pages/HomePage/App.tsx | 38 + .../src/pages/HomePage/DeputyMessage.tsx | 409 ++++ .../backoffice/src/pages/HomePage/Footer.tsx | 367 ++++ .../backoffice/src/pages/HomePage/Header.tsx | 702 ++++++ .../src/pages/HomePage/NewsSection.tsx | 452 ++++ .../src/pages/HomePage/OfficeHeadMessage.tsx | 318 +++ .../src/pages/HomePage/OrganizationGoal.tsx | 291 +++ .../backoffice/src/pages/LoginPage.tsx | 16 + .../src/pages/OrgAdminDashboard.tsx | 347 +++ .../src/pages/OrganizationAdminsPage.tsx | 7 + .../Organizations/AdminRegistrationPage.tsx | 9 + .../Organizations/EditOrganizationPage.tsx | 9 + .../Organizations/NewOrganizationPage.tsx | 7 + .../Organizations/OrganizationDetailPage.tsx | 22 + .../pages/Organizations/OrganizationsPage.tsx | 7 + .../src/pages/PositionConfigurationPage.tsx | 531 +++++ .../backoffice/src/pages/SettingsPage.tsx | 224 ++ .../src/pages/SuperAdminArchiveUsersPage.tsx | 146 ++ .../src/pages/SuperAdminArchivedPage.tsx | 210 ++ .../src/pages/UnitConfigurationPage.tsx | 1937 +++++++++++++++++ .../src/pages/UploadedDocumentViewPage.tsx | 14 + .../src/pages/UserManagementPage.tsx | 9 + .../src/pages/UserProfileEditPage.tsx | 9 + .../src/pages/WebManagementPage.tsx | 7 + 36 files changed, 8267 insertions(+) create mode 100644 apps/edr-freight-web/backoffice/src/pages/ActivityLogPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/AddSitePage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/AdvancedDashboardPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/ArchiveUsersPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/ArchivedUnitsPositionsPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/AttachmentSignature.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/AuditLog.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/BulkUploadPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/ConfigurationPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/ContentManagementPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/DashboardPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/EscalationConfigurationPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/HomePage/App.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/HomePage/DeputyMessage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/HomePage/Footer.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/HomePage/Header.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/HomePage/NewsSection.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/HomePage/OfficeHeadMessage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/HomePage/OrganizationGoal.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/LoginPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/OrgAdminDashboard.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/OrganizationAdminsPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/Organizations/AdminRegistrationPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/Organizations/EditOrganizationPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/Organizations/NewOrganizationPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/Organizations/OrganizationDetailPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/Organizations/OrganizationsPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/PositionConfigurationPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/SettingsPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/SuperAdminArchiveUsersPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/SuperAdminArchivedPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/UnitConfigurationPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/UploadedDocumentViewPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/UserManagementPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/UserProfileEditPage.tsx create mode 100644 apps/edr-freight-web/backoffice/src/pages/WebManagementPage.tsx diff --git a/apps/edr-freight-web/backoffice/src/pages/ActivityLogPage.tsx b/apps/edr-freight-web/backoffice/src/pages/ActivityLogPage.tsx new file mode 100644 index 000000000..9e3f53da3 --- /dev/null +++ b/apps/edr-freight-web/backoffice/src/pages/ActivityLogPage.tsx @@ -0,0 +1,268 @@ +import { useState, useEffect, useCallback } from "react"; +import { useTranslation } from "react-i18next"; +import i18n from "i18next"; +import { + Card, + CardContent, + CardHeader, + CardTitle, +} from "@/shared/common/ui/card"; +import { + Table, + TableHeader, + TableRow, + TableHead, + TableBody, + TableCell, +} from "@/shared/common/ui/table"; +import { Input } from "@/shared/common/ui/input"; +import { Button } from "@/shared/common/ui/button"; +import { Search, RefreshCw, ChevronLeft, ChevronRight } from "lucide-react"; +import { listAuditLogExtensions } from "@/shared/services/audit/audit.api"; + +interface ActivityLog { + id: string; + createdAt: string; + entityName: string; + queryMethod: "INSERT" | "UPDATE" | "DELETE" | string; + user: { + id: string; + name: { + am: string; + en: string; + }; + email: string; + username?: string; + }; +} + +const ITEMS_PER_PAGE = 10; + +export default function ActivityLogPage() { + const { t } = useTranslation(); + const [searchQuery, setSearchQuery] = useState(""); + const [allLogs, setAllLogs] = useState([]); + const [filteredLogs, setFilteredLogs] = useState([]); + const [loading, setLoading] = useState(false); + const [currentPage, setCurrentPage] = useState(1); + + const fetchAuditLogs = useCallback(async () => { + setLoading(true); + try { + // Fetch all 1000 records from super admin endpoint + const data = await listAuditLogExtensions( + "/audit-log-extensions/audit/superAdmin", + { + skip: 0, + take: 1000, + orderBy: "createdAt:DESC", + } + ); + + const logs = (data.items || []) as ActivityLog[]; + setAllLogs(logs); + setCurrentPage(1); + } catch (error: any) { + console.error("Error fetching audit logs:", error); + setAllLogs([]); + } finally { + setLoading(false); + } + }, []); + + useEffect(() => { + fetchAuditLogs(); + // Refresh every 30 seconds + const interval = setInterval(fetchAuditLogs, 30000); + return () => clearInterval(interval); + }, [fetchAuditLogs]); + + // Paginate the logs whenever currentPage changes + useEffect(() => { + const startIndex = (currentPage - 1) * ITEMS_PER_PAGE; + const endIndex = startIndex + ITEMS_PER_PAGE; + let filtered = allLogs.slice(startIndex, endIndex); + + // Apply search filter + if (searchQuery) { + filtered = filtered.filter( + (log) => + log.entityName.toLowerCase().includes(searchQuery.toLowerCase()) || + log.user.name.am.toLowerCase().includes(searchQuery.toLowerCase()) || + log.user.name.en.toLowerCase().includes(searchQuery.toLowerCase()) || + log.user.email.toLowerCase().includes(searchQuery.toLowerCase()), + ); + } + + setFilteredLogs(filtered); + }, [allLogs, currentPage, searchQuery]); + + const totalPages = Math.ceil(allLogs.length / ITEMS_PER_PAGE); + const hasNextPage = currentPage < totalPages; + const hasPrevPage = currentPage > 1; + + return ( +
+ + +
+ + {t("activityLogPage.title")} + + +
+
+ +
+
+ + setSearchQuery(e.target.value)} + className="pl-10" + /> +
+
+ +
+ + + + + {t("activityLogPage.table.time")} + + + {t("activityLogPage.table.description")} + + + {t("activityLogPage.table.performedBy")} + + + + + {loading ? ( + + +
+ + {t("common.loading", "Loading...")} +
+
+
+ ) : filteredLogs.length > 0 ? ( + filteredLogs.map((log) => { + const userName = + i18n.language === "am" ? log.user.name.am : log.user.name.en; + const entityLabel = log.entityName.replace(/_/g, " "); + const actionVerb = + log.queryMethod.toLowerCase() === "insert" + ? "created" + : log.queryMethod.toLowerCase() === "update" + ? "updated" + : log.queryMethod.toLowerCase() === "delete" + ? "deleted" + : log.queryMethod.toLowerCase(); + const timestamp = new Date(log.createdAt).toLocaleString( + i18n.language, + { + year: "numeric", + month: "short", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + } + ); + + return ( + + {timestamp} + +

+ {userName} + {" "} + + {actionVerb} + + {" "} + + {entityLabel} + + {" "} + at {timestamp} +

+
+ +
+

{userName}

+

{log.user.email}

+
+
+
+ ); + }) + ) : ( + + + {t("activityLogPage.table.noLogs")} + + + )} +
+
+
+ + {/* Pagination Footer */} + {allLogs.length > 0 && ( +
+
+ {t("common.showing", "Showing")} {(currentPage - 1) * ITEMS_PER_PAGE + 1}- + {Math.min(currentPage * ITEMS_PER_PAGE, allLogs.length)}{" "} + {t("common.of", "of")} {allLogs.length} +
+ +
+ + +
+ + {currentPage} / {totalPages || 1} + +
+ + +
+
+ )} +
+
+
+ ); +} diff --git a/apps/edr-freight-web/backoffice/src/pages/AddSitePage.tsx b/apps/edr-freight-web/backoffice/src/pages/AddSitePage.tsx new file mode 100644 index 000000000..fdd26eca4 --- /dev/null +++ b/apps/edr-freight-web/backoffice/src/pages/AddSitePage.tsx @@ -0,0 +1,7 @@ +import SitesPage from "@/super-admin/components/sites/SitesPage"; + +const AddSitePage = () => { + return ; +}; + +export default AddSitePage; diff --git a/apps/edr-freight-web/backoffice/src/pages/AdvancedDashboardPage.tsx b/apps/edr-freight-web/backoffice/src/pages/AdvancedDashboardPage.tsx new file mode 100644 index 000000000..429f931e6 --- /dev/null +++ b/apps/edr-freight-web/backoffice/src/pages/AdvancedDashboardPage.tsx @@ -0,0 +1,141 @@ +import React, { useState } from "react"; +import { Button } from "@/shared/common/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuTrigger, +} from "@/shared/common/ui/dropdown-menu"; +import { ChevronDown } from "lucide-react"; +import { + PermittedDashboardItem, + DashaboardParam, +} from "@/record-management/services/api/advancedDashboardService"; +import { useAdvancedDashboardHook } from "@/shared/hooks/useAdvancedDashboardHook"; +import useSettings from "@/record-management/components/hooks/useSettings"; +import { useLocalizedName } from "@/shared/common/localizedName"; +import { getFormattedDashboardLabel } from "@/performance-management/utils/dashboardUtils"; +import { PositionDto } from "@/record-management/dto/userRecords/usersDto"; + +const AdvancedDashboardPage = () => { + const [selectedDashboard, setSelectedDashboard] = + useState(null); + const [selectedParameters, setSelectedParameters] = useState< + Record + >({}); + const localizedName = useLocalizedName(); + + const { + permittedDashboards, + dashboardUrl, + isLoadingPermitted, + isLoadingUrl, + } = useAdvancedDashboardHook(selectedDashboard?.id); + + const { allScopedDepartments, allScopedEmployees } = useSettings(); + + const positionOptions = Array.isArray(allScopedDepartments) + ? allScopedDepartments.map((pos: PositionDto) => ({ + label: localizedName(pos.name) || "N/A", + value: pos.id, + })) + : []; + + const employeeOptions = Array.isArray(allScopedEmployees) + ? allScopedEmployees.map((emp: any) => ({ + label: localizedName(emp.name) || "N/A", + value: emp.id, + })) + : []; + + const handleParameterSelect = (key: string, value: string) => { + setSelectedParameters((prev) => ({ + ...prev, + [key]: value, + })); + }; + + return ( +
+ {/* Dashboard + Position + Employee in a row */} +
+ {/* Dashboard Dropdown */} + + + + + + Available Dashboards + {permittedDashboards?.items.map((dashboard) => ( + { + setSelectedDashboard(dashboard); + setSelectedParameters({}); // reset parameters + }}> + {getFormattedDashboardLabel(dashboard.name, "am")} + + ))} + + + + {/* Position Dropdown */} + {selectedDashboard?.params?.includes(DashaboardParam.POSITION) && ( + + )} + + {/* Employee Dropdown */} + {selectedDashboard?.params?.includes(DashaboardParam.EMPLOYEE) && ( + + )} +
+ + {/* Dashboard iframe */} + {isLoadingUrl ? ( +

Loading dashboard...

+ ) : dashboardUrl ? ( +