import { useMutation, useQuery } from "@tanstack/react-query"; import { ArrowLeft, ChevronLeft, ChevronRight, Filter, Search, } from "lucide-react"; import { useState } from "react"; import { Link, useParams } from "react-router-dom"; import { Badge } from "../../components/ui/badge"; import { Button } from "../../components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "../../components/ui/card"; import { Input } from "../../components/ui/input"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../../components/ui/table"; import { fetchClient, fetchConsents, revokeConsent } from "../../lib/devApi"; function ClientConsentsPage() { const params = useParams(); const clientId = params.id ?? ""; const [subjectInput, setSubjectInput] = useState(""); const [subject, setSubject] = useState(""); const { data: clientData } = useQuery({ queryKey: ["client", clientId], queryFn: () => fetchClient(clientId), enabled: clientId.length > 0, }); const { data: consentsData, isLoading, error, refetch, } = useQuery({ queryKey: ["consents", clientId, subject], queryFn: () => fetchConsents(subject, clientId), enabled: clientId.length > 0, // Removed subject.length > 0 check }); const revokeMutation = useMutation({ mutationFn: (payload: { subject: string }) => revokeConsent(payload.subject, clientId), onSuccess: () => { refetch(); }, }); const rows = consentsData?.items ?? []; return (

User Consent Grants

OIDC Relying Party 사용자 권한을 검토·관리합니다.

{clientData?.client?.status === "active" ? "Active" : "Inactive"}
Connection Consent & Users Settings
setSubjectInput(e.target.value)} />
Status:
{error && ( Error loading consents: {(error as Error).message} )} {isLoading && ( Loading consents... )} User Tenant Status Granted Scopes First Granted Last Authenticated Action {rows.length === 0 && !isLoading ? ( No consents found. ) : ( rows.map((row) => (
{(row.userName || row.subject).slice(0, 2).toUpperCase()}
{row.userName || "Subject"} {row.subject}
{row.tenantName || "N/A"} {row.tenantId}
Active
{row.grantedScopes.map((scope) => ( {scope} ))}
{new Date(row.createdAt).toLocaleString()} {row.authenticatedAt ? new Date(row.authenticatedAt).toLocaleString() : "-"}
)) )}

Showing {rows.length > 0 ? 1 : 0} to{" "} {rows.length} of{" "} {rows.length} users

Active Grants

{rows.length}

Total Scopes Issued

{rows.reduce((acc, row) => acc + row.grantedScopes.length, 0)}

Avg. Scopes per User

{rows.length > 0 ? ( rows.reduce((acc, row) => acc + row.grantedScopes.length, 0) / rows.length ).toFixed(1) : "0.0"}
); } export default ClientConsentsPage;