mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
WIP
This commit is contained in:
@@ -47,10 +47,10 @@ const baseSidebarItems: SidebarItem[] = [
|
||||
label: "Position Type",
|
||||
href: "/dashboard/user-management/position-types",
|
||||
},
|
||||
{
|
||||
label: "Employees",
|
||||
href: "/dashboard/user-management/employees",
|
||||
},
|
||||
// {
|
||||
// label: "Employees",
|
||||
// href: "/dashboard/user-management/employees",
|
||||
// },
|
||||
{
|
||||
label: "Permissions",
|
||||
href: "/dashboard/user-management/permissions",
|
||||
|
||||
@@ -785,13 +785,19 @@ const UserManagementPage = () => {
|
||||
const refreshSelectedUnit = useCallback(async () => {
|
||||
if (!selectedUnitId) {
|
||||
setPositions([]);
|
||||
setPositionTypes([]);
|
||||
setPositionTypesError(null);
|
||||
setPositionMembers([]);
|
||||
setUnitAdminUserIds(new Set());
|
||||
return;
|
||||
}
|
||||
|
||||
await Promise.all([loadPositions(selectedUnitId), loadUnitAdmins(selectedUnitId)]);
|
||||
}, [loadPositions, loadUnitAdmins, selectedUnitId]);
|
||||
await Promise.all([
|
||||
loadPositions(selectedUnitId),
|
||||
loadPositionTypes(selectedUnitId),
|
||||
loadUnitAdmins(selectedUnitId),
|
||||
]);
|
||||
}, [loadPositionTypes, loadPositions, loadUnitAdmins, selectedUnitId]);
|
||||
|
||||
useEffect(() => {
|
||||
void loadOrganizations();
|
||||
@@ -850,9 +856,23 @@ const UserManagementPage = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!units.some((unit) => unit.id === selectedUnitId)) {
|
||||
setSelectedUnitId(null);
|
||||
if (units.some((unit) => unit.id === selectedUnitId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSelectedUnitId(units[0]?.id ?? null);
|
||||
}, [selectedOrgId, selectedUnitId, units]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedOrgId || !units.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedUnitId && units.some((unit) => unit.id === selectedUnitId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSelectedUnitId(units[0]?.id ?? null);
|
||||
}, [selectedOrgId, selectedUnitId, units]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -868,6 +888,14 @@ const UserManagementPage = () => {
|
||||
}
|
||||
}, [selectedUnitId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedUnitId) {
|
||||
return;
|
||||
}
|
||||
|
||||
void refreshSelectedUnit();
|
||||
}, [refreshSelectedUnit, selectedUnitId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedUnitId || !selectedPositionId) {
|
||||
return;
|
||||
@@ -930,15 +958,11 @@ const UserManagementPage = () => {
|
||||
setSelectedPositionId(null);
|
||||
setExpandedDepartmentIds(new Set());
|
||||
setPositions([]);
|
||||
setPositionTypes([]);
|
||||
setPositionTypesError(null);
|
||||
setPositionMembers([]);
|
||||
setUnitAdminUserIds(new Set());
|
||||
resetMessages();
|
||||
|
||||
try {
|
||||
await Promise.all([loadPositions(unitId), loadUnitAdmins(unitId)]);
|
||||
} catch {
|
||||
// Individual loaders already handle their own error state.
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleDepartment = (departmentId: string) => {
|
||||
|
||||
Reference in New Issue
Block a user