diff --git a/adminfront/src/features/tenants/routes/TenantFederationPage.tsx b/adminfront/src/features/tenants/routes/TenantFederationPage.tsx index e3c08d62..ca36003d 100644 --- a/adminfront/src/features/tenants/routes/TenantFederationPage.tsx +++ b/adminfront/src/features/tenants/routes/TenantFederationPage.tsx @@ -1,9 +1,167 @@ import { useParams } from "react-router-dom"; -import { useQuery } from "@tanstack/react-query"; -import { listIdpConfigsForTenant } from "../../../lib/adminApi"; +import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import { createIdpConfig, listIdpConfigsForTenant } from "../../../lib/adminApi"; +import type { IdpConfigCreateRequest, IdpConfig } from "../../../lib/adminApi"; +import { useState } from "react"; + +// Proper Modal Component with Form +const CreateIdpModal = ({ + isOpen, + onClose, + tenantId, +}: { + isOpen: boolean; + onClose: () => void; + tenantId: string; +}) => { + const queryClient = useQueryClient(); + const [formData, setFormData] = useState({ + tenant_id: tenantId, + provider_type: "oidc", + display_name: "", + status: "active", + issuer_url: "", + client_id: "", + client_secret: "", + scopes: "openid email profile", + }); + + const mutation = useMutation({ + mutationFn: (newData: IdpConfigCreateRequest) => createIdpConfig(newData), + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ["idpConfigs", tenantId] }); + onClose(); + }, + onError: (error) => { + // Basic error handling + alert(`Failed to create configuration: ${error.message}`); + }, + }); + + // 이 내용으로 교체해주세요 + const handleChange = ( + e: React.ChangeEvent, + ) => { + const { name, value } = e.target; + setFormData((prev) => ({ + ...prev, + [name]: value, + })); + }; + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + mutation.mutate(formData); + }; + + if (!isOpen) return null; + + return ( +
+
+

Add New IdP Configuration

+
+ {/* Display Name */} +
+ + +
+ + {/* Issuer URL */} +
+ + +
+ + {/* Client ID */} +
+ + +
+ + {/* Client Secret */} +
+ + +
+ + {/* Scopes */} +
+ + +
+ + {/* Action Buttons */} +
+ + +
+
+
+
+ ); +}; export function TenantFederationPage() { const { tenantId } = useParams<{ tenantId: string }>(); + const [isCreateModalOpen, setCreateModalOpen] = useState(false); if (!tenantId) { return
Tenant ID is missing
; @@ -16,19 +174,26 @@ export function TenantFederationPage() { return (
-

- Identity Federation Settings -

+

Identity Federation Settings

Manage external identity providers for this tenant.

-
+ setCreateModalOpen(false)} + tenantId={tenantId} + /> + {isLoading &&
Loading configurations...
} {error && (
@@ -55,7 +220,7 @@ export function TenantFederationPage() { ) : ( - data.map((config) => ( + data.map((config: IdpConfig) => ( {config.display_name}