feat(freight:backoffice): migrated smart-office user-management

This commit is contained in:
Michael Abebe
2026-05-26 12:50:40 +03:00
parent a8d26b73b8
commit b487d47055
9 changed files with 2350 additions and 15 deletions

View File

@@ -1,14 +1,11 @@
import { Navigate, Outlet, Route, Routes, useLocation, useNavigate } from "react-router-dom";
import { DashboardLayout, type SidebarItem } from "@edr/ui-common";
import { LayoutDashboard, ShieldCheck, Users, Network } from "lucide-react";
import { LayoutDashboard, Network } from "lucide-react";
import { useAuth } from "./auth/useAuth";
import LoginPage from "./pages/auth/LoginPage";
import OverviewPage from "./pages/dashboard/OverviewPage";
import UsersPage from "./pages/dashboard/user-management/UsersPage";
import RolesPage from "./pages/dashboard/user-management/RolesPage";
import DepartmentsPage from "./pages/dashboard/user-management/DepartmentsPage";
import OrgStructurePage from "./pages/dashboard/org-structure/OrgStructurePage";
import UserManagementPage from "./pages/dashboard/user-management/UserManagementPage";
import LoadingScreen from "./components/LoadingScreen";
const sidebarItems: SidebarItem[] = [
@@ -18,8 +15,8 @@ const sidebarItems: SidebarItem[] = [
icon: <LayoutDashboard />,
},
{
label: "Org structure",
href: "/dashboard/org-structure",
label: "User management",
href: "/dashboard/user-management",
icon: <Network />,
},
];
@@ -69,9 +66,9 @@ const App = () => {
<Route path="/dashboard" element={<Navigate to="/dashboard/overview" replace />} />
<Route path="/dashboard" element={<DashboardShell />}>
<Route path="overview" element={<OverviewPage />} />
<Route path="org-structure" element={<OrgStructurePage />} />
<Route path="org-structure/units/:unitId" element={<OrgStructurePage />} />
<Route path="org-structure/units/:unitId/:section" element={<OrgStructurePage />} />
<Route path="user-management" element={<UserManagementPage />} />
<Route path="org-structure" element={<Navigate to="/dashboard/user-management" replace />} />
<Route path="org-structure/*" element={<Navigate to="/dashboard/user-management" replace />} />
</Route>
<Route path="*" element={<Navigate to="/dashboard/overview" replace />} />
</Routes>

View File

@@ -125,8 +125,15 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
mfaEmailRef.current = null;
},
logout: () => {
const preservedTheme = window.localStorage.getItem("edr-theme");
clearSessionCookies();
localStorage.clear();
window.localStorage.clear();
if (preservedTheme === "dark" || preservedTheme === "light") {
window.localStorage.setItem("edr-theme", preservedTheme);
}
setUser(null);
window.location.replace("/auth");
},

View File

@@ -1,11 +1,47 @@
interface LocaleText {
en?: string;
am?: string;
}
interface AuthRole {
id?: string;
key?: string;
}
interface AuthPermission {
id?: string;
key?: string;
}
interface AuthEmployeePosition {
id?: string;
employeePositionId?: string;
name?: LocaleText;
key?: string;
isDelegate?: boolean;
parentPositionId?: string | null;
permissions?: AuthPermission[];
}
interface AuthEmployeeRecord {
id?: string;
organizationId?: string;
unitId?: string;
name?: LocaleText;
positions?: AuthEmployeePosition[];
}
export interface AuthUser {
id?: string;
email?: string;
username?: string;
name?: {
en?: string;
am?: string;
};
phoneNumber?: string;
name?: LocaleText;
roles?: AuthRole[];
permissions?: AuthPermission[];
employee?: AuthEmployeeRecord[];
hasSetPassword?: boolean;
status?: string;
}
export interface AuthTokens {