import { useState } from "react"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Link2, CheckCircle2, AlertCircle, Loader2 } from "lucide-react"; export default function Link() { const [code, setCode] = useState(""); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); const [error, setError] = useState(""); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!code.trim() || code.length !== 6) { setError("Please enter a valid 6-character code"); return; } setLoading(true); setError(""); setSuccess(false); try { const response = await fetch("/api/auth/verify-device-code", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ code: code.toUpperCase() }) }); const data = await response.json(); if (!response.ok) { throw new Error(data.message || "Failed to link device"); } setSuccess(true); setCode(""); } catch (err: any) { setError(err.message || "Failed to link device. Please try again."); } finally { setLoading(false); } }; return (
Where to find your code: