1
0
forked from baron/baron-sso

feat: optimize tenant admin view and enhance user list with dynamic columns and metadata search

This commit is contained in:
2026-03-04 13:32:01 +09:00
parent 02acdf835f
commit d1c3bba3e0
8 changed files with 206 additions and 67 deletions

View File

@@ -23,17 +23,32 @@ import {
import {
type TenantSummary,
deleteTenant,
fetchMe,
fetchTenants,
} from "../../../lib/adminApi";
import { t } from "../../../lib/i18n";
import { RoleGuard } from "../../../components/auth/RoleGuard";
function TenantListPage() {
const navigate = useNavigate();
const { data: profile } = useQuery({
queryKey: ["me"],
queryFn: fetchMe,
});
// Redirect tenant_admin to their own tenant
React.useEffect(() => {
if (profile?.role === "tenant_admin" && profile?.tenantId) {
navigate(`/tenants/${profile.tenantId}`, { replace: true });
}
}, [profile, navigate]);
const query = useQuery({
queryKey: ["tenants", { limit: 1000, offset: 0 }],
queryFn: () => fetchTenants(1000, 0),
enabled: profile?.role === "super_admin",
});
const navigate = useNavigate();
const deleteMutation = useMutation({
mutationFn: (tenantId: string) => deleteTenant(tenantId),
onSuccess: () => {
@@ -41,6 +56,20 @@ function TenantListPage() {
},
});
if (profile && profile.role !== "super_admin" && profile.role !== "tenant_admin") {
return (
<div className="flex h-[50vh] flex-col items-center justify-center space-y-4">
<h3 className="text-xl font-bold">{t("msg.admin.common.forbidden", "접근 권한이 없습니다.")}</h3>
<Button onClick={() => navigate("/")}>{t("ui.common.go_home", "홈으로 이동")}</Button>
</div>
);
}
// While redirecting
if (profile?.role === "tenant_admin") {
return null;
}
const errorMsg = (query.error as AxiosError<{ error?: string }>)?.response
?.data?.error;
const fallbackError =
@@ -95,12 +124,14 @@ function TenantListPage() {
<RefreshCw size={16} />
{t("ui.common.refresh", "새로고침")}
</Button>
<Button asChild>
<Link to="/tenants/new">
<Plus size={16} />
{t("ui.admin.tenants.add", "테넌트 추가")}
</Link>
</Button>
<RoleGuard roles={["super_admin"]}>
<Button asChild>
<Link to="/tenants/new">
<Plus size={16} />
{t("ui.admin.tenants.add", "테넌트 추가")}
</Link>
</Button>
</RoleGuard>
</div>
</header>