"use client"; import { useState } from "react"; import { api, errorText } from "@/lib/api"; export type OauthParams = Partial< Record< | "response_type" | "client_id" | "redirect_uri" | "code_challenge" | "code_challenge_method" | "scope" | "state" | "resource", string > >; /** The admin's answer: the backend gives the address back to the client (with a code, or a refusal). */ export function Approve({ params }: { params: OauthParams }) { const [busy, setBusy] = useState(false); const [error, setError] = useState(null); async function answer(deny: boolean) { setBusy(true); setError(null); try { const r = await api<{ redirect_to: string }>("/oauth/authorize", { body: { ...params, deny } }); window.location.assign(r.redirect_to); } catch (e) { setError(errorText(e)); setBusy(false); } } return (
{error && (

{error}

)}
); }