forked from baron/baron-sso
af 린트 적용
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import {
|
||||
type UseMutationResult,
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query";
|
||||
import type { AxiosError } from "axios";
|
||||
import {
|
||||
ChevronDown,
|
||||
@@ -57,15 +61,15 @@ function buildGroupTree(
|
||||
const childrenOf = new Map<string, UserGroupNode[]>();
|
||||
|
||||
// First pass: Initialize all groups as nodes and populate childrenOf map
|
||||
groups.forEach((group) => {
|
||||
for (const group of groups) {
|
||||
childrenOf.set(group.id, []);
|
||||
});
|
||||
}
|
||||
|
||||
// Second pass: Populate children
|
||||
groups.forEach((group) => {
|
||||
for (const group of groups) {
|
||||
const node: UserGroupNode = {
|
||||
...group,
|
||||
children: childrenOf.get(group.id)!,
|
||||
children: childrenOf.get(group.id) ?? [],
|
||||
};
|
||||
if (group.parentId === parentId) {
|
||||
nodes.push(node);
|
||||
@@ -79,13 +83,13 @@ function buildGroupTree(
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Sort children for consistent rendering (optional, but good for UI)
|
||||
nodes.sort((a, b) => a.name.localeCompare(b.name));
|
||||
nodes.forEach((node) => {
|
||||
for (const node of nodes) {
|
||||
node.children.sort((a, b) => a.name.localeCompare(b.name));
|
||||
});
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
@@ -97,8 +101,16 @@ interface UserGroupTreeNodeProps {
|
||||
selectedGroupId: string | null;
|
||||
onDelete: (groupId: string) => void;
|
||||
onAddSubGroup: (parentId: string) => void;
|
||||
addMemberMutation: any; // Simplified type for now
|
||||
removeMemberMutation: any; // Simplified type for now
|
||||
addMemberMutation: UseMutationResult<
|
||||
void,
|
||||
AxiosError<{ error?: string }>,
|
||||
{ groupId: string; userId: string }
|
||||
>;
|
||||
removeMemberMutation: UseMutationResult<
|
||||
void,
|
||||
AxiosError<{ error?: string }>,
|
||||
{ groupId: string; userId: string }
|
||||
>;
|
||||
}
|
||||
|
||||
const UserGroupTreeNode: React.FC<UserGroupTreeNodeProps> = ({
|
||||
|
||||
@@ -38,7 +38,9 @@ function buildTenantTree(tenants: TenantSummary[]): TenantNode[] {
|
||||
}
|
||||
|
||||
for (const tenant of tenants) {
|
||||
const node = tenantMap.get(tenant.id)!;
|
||||
const node = tenantMap.get(tenant.id);
|
||||
if (!node) continue;
|
||||
|
||||
if (tenant.parentId) {
|
||||
const parent = tenantMap.get(tenant.parentId);
|
||||
if (parent) {
|
||||
|
||||
Reference in New Issue
Block a user