forked from baron/baron-sso
린트 적용
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import * as React from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type * as React from "react";
|
||||
import { fetchMe } from "../../lib/adminApi";
|
||||
|
||||
interface RoleGuardProps {
|
||||
@@ -10,13 +10,17 @@ interface RoleGuardProps {
|
||||
|
||||
/**
|
||||
* RoleGuard conditionally renders children based on the current user's role.
|
||||
*
|
||||
*
|
||||
* Usage:
|
||||
* <RoleGuard roles={['super_admin']}>
|
||||
* <button>System Only Action</button>
|
||||
* </RoleGuard>
|
||||
*/
|
||||
export function RoleGuard({ children, roles, fallback = null }: RoleGuardProps) {
|
||||
export function RoleGuard({
|
||||
children,
|
||||
roles,
|
||||
fallback = null,
|
||||
}: RoleGuardProps) {
|
||||
const { data: profile, isLoading } = useQuery({
|
||||
queryKey: ["me"],
|
||||
queryFn: fetchMe,
|
||||
|
||||
@@ -55,7 +55,7 @@ function AppLayout() {
|
||||
const manageableCount = profile?.manageableTenants?.length ?? 0;
|
||||
|
||||
// Filter out restricted items for non-super admins
|
||||
const filteredItems = items.filter(item => {
|
||||
const filteredItems = items.filter((item) => {
|
||||
if (item.to === "/api-keys") return isSuperAdmin;
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user