"use client"; import Image from 'next/image'; import { useState } from "react"; import { useGoogleLogin } from "@react-oauth/google"; import { useTheme } from 'next-themes'; import { Sun, Moon } from 'lucide-react'; interface KeycloakTokenResponse { access_token: string; expires_in: number; refresh_expires_in: number; refresh_token: string; token_type: string; id_token?: string; "not-before-policy": number; session_state: string; scope: string; } export default function AppleStyleAuth() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const { theme, setTheme } = useTheme(); const [mounted, setMounted] = useState(false); const handleManualLogin = async (): Promise => { const details: Record = { grant_type: 'password', client_id: 'tvone-web-client', username: email, password: password, scope: 'openid', }; try { const response = await fetch( 'https://keycloak.petermaquiran.xyz/realms//protocol/openid-connect/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams(details).toString(), } ); const data: KeycloakTokenResponse = await response.json(); if (data.access_token) { localStorage.setItem("token", data.access_token); } } catch (err) { console.error("Login failed", err); } }; return (
{/* THEME TOGGLE BUTTON */}
{/* 1. LOGOTIPO */}
logo

Iniciar sessão

Usa a tua conta TVone.

{/* 2. FORMULÁRIO */}
setEmail(e.target.value)} className="w-full rounded-2xl border border-neutral-200 bg-white/50 px-5 py-4 text-sm outline-none transition-all focus:border-blue-500 focus:bg-white focus:text-black focus:ring-4 focus:ring-blue-500/10 dark:border-neutral-800 dark:bg-neutral-900 dark:text-white" /> setPassword(e.target.value)} className="w-full rounded-2xl border border-neutral-200 bg-white/50 px-5 py-4 text-sm outline-none transition-all focus:border-blue-500 focus:bg-white focus:text-black focus:ring-4 focus:ring-blue-500/10 dark:border-neutral-800 dark:bg-neutral-900 dark:text-white" />
{/* 3. DIVISOR */}
ou
{/* 4. BOTÃO GOOGLE */} {/* 5. LINKS */}
); }