forked from baron/baron-sso
개발자 권한 접근 로직 공통화
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
OverviewSelectionChips,
|
||||
} from "../../../../common/core/components/overview";
|
||||
import { DeveloperAccessRequestCard } from "../../components/common/DeveloperAccessRequestCard";
|
||||
import { useDeveloperAccessGate } from "../developer-access/developerAccessGate";
|
||||
import {
|
||||
type ClientSummary,
|
||||
fetchClients,
|
||||
@@ -491,11 +492,6 @@ function GlobalOverviewPage() {
|
||||
const [period, setPeriod] = useState<RPUsagePeriod>("day");
|
||||
const [selectedClientIds, setSelectedClientIds] = useState<string[]>([]);
|
||||
const usageDays = period === "day" ? 14 : period === "week" ? 84 : 90;
|
||||
const { data: requestStatus, isLoading: isLoadingRequestStatus } = useQuery({
|
||||
queryKey: ["developer-request", tenantId],
|
||||
queryFn: () => fetchDeveloperRequestStatus(tenantId),
|
||||
enabled: hasAccessToken && profileRole === "user",
|
||||
});
|
||||
const statsQuery = useQuery({
|
||||
queryKey: ["dev-dashboard-stats"],
|
||||
queryFn: fetchDevStats,
|
||||
@@ -517,17 +513,17 @@ function GlobalOverviewPage() {
|
||||
});
|
||||
|
||||
const clients = clientsQuery.data?.items ?? [];
|
||||
const hasDeveloperAccess =
|
||||
profileRole === "super_admin" ||
|
||||
profileRole === "tenant_admin" ||
|
||||
profileRole === "rp_admin" ||
|
||||
requestStatus?.status === "approved";
|
||||
const isDeveloperRequestPending = requestStatus?.status === "pending";
|
||||
const canRequestDeveloperAccess =
|
||||
profileRole === "user" &&
|
||||
!isLoadingRequestStatus &&
|
||||
!hasDeveloperAccess &&
|
||||
!isDeveloperRequestPending;
|
||||
const {
|
||||
hasDeveloperAccess,
|
||||
isDeveloperRequestPending,
|
||||
canRequestDeveloperAccess,
|
||||
isLoadingDeveloperAccessGate,
|
||||
} = useDeveloperAccessGate({
|
||||
hasAccessToken,
|
||||
profileRole,
|
||||
tenantId,
|
||||
isLoadingIdentity: isLoadingMe,
|
||||
});
|
||||
const distribution = useMemo(
|
||||
() => buildClientDistribution(clients),
|
||||
[clients],
|
||||
@@ -616,8 +612,7 @@ function GlobalOverviewPage() {
|
||||
};
|
||||
|
||||
if (
|
||||
profileRole === "user" &&
|
||||
(isLoadingMe || isLoadingRequestStatus)
|
||||
isLoadingDeveloperAccessGate
|
||||
) {
|
||||
return (
|
||||
<div className="p-8 text-center">
|
||||
|
||||
Reference in New Issue
Block a user