"use client"; import { completeDeviceAuthorization } from "@/lib/server/device"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { Alert } from "./alert"; import { Button, ButtonVariants } from "./button"; import { Spinner } from "./spinner"; import { Translated } from "./translated"; export function ConsentScreen({ scope, nextUrl, deviceAuthorizationRequestId, appName, }: { scope?: string[]; nextUrl: string; deviceAuthorizationRequestId: string; appName?: string; }) { const t = useTranslations(); const [loading, setLoading] = useState(false); const [error, setError] = useState(""); const router = useRouter(); async function denyDeviceAuth() { setLoading(true); const response = await completeDeviceAuthorization(deviceAuthorizationRequestId) .catch(() => { setError("Could not register user"); return; }) .finally(() => { setLoading(false); }); if (response) { return router.push("/device"); } } const scopes = scope?.filter((s) => !!s); return (
    {scopes?.length === 0 && ( )} {scopes?.map((s) => { const translationKey = `device.scope.${s}`; const description = t(translationKey); // Check if the key itself is returned and provide a fallback const resolvedDescription = description === translationKey ? "" : description; return (
  • {resolvedDescription}
  • ); })}

{error && (
{error}
)}
); }