"use client"; import { useState, useEffect } from "react"; import { Loader2, Save } from "lucide-react"; import { toast } from "sonner"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; export default function SettingsPage() { const [settings, setSettings] = useState>({}); const [isLoading, setIsLoading] = useState(true); const [isSaving, setIsSaving] = useState(false); useEffect(() => { fetchSettings(); }, []); async function fetchSettings() { try { const response = await fetch("/api/admin/settings"); if (!response.ok) throw new Error("Failed to fetch settings"); const data = await response.json(); setSettings(data.settings); } catch (error) { toast.error("Failed to load settings"); } finally { setIsLoading(false); } } async function handleSave() { setIsSaving(true); try { const response = await fetch("/api/admin/settings", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ settings }), }); if (!response.ok) throw new Error("Failed to save settings"); toast.success("Settings saved successfully"); } catch (error) { toast.error("Failed to save settings"); } finally { setIsSaving(false); } } function updateSetting(key: string, value: string) { setSettings((prev) => ({ ...prev, [key]: value })); } if (isLoading) { return (
); } return (

Settings

Configure application settings

Microsoft Sessions Audit Microsoft Entra ID Configure Microsoft 365 authentication settings
updateSetting("microsoft_tenant_id", e.target.value)} placeholder="common or your-tenant-id" />

Use "common" for multi-tenant or specify your organization's tenant ID

Session Settings Configure session timeout and security policies
updateSetting("default_session_timeout", e.target.value)} />

Default: 86400 (24 hours)

Audit Log Settings Configure audit log retention
updateSetting("audit_log_retention_days", e.target.value)} />

Audit logs older than this will be automatically deleted

); }