"use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { BirthForm } from "@/app/profil/BirthForm"; import { api, errorText } from "@/lib/api"; /** The logged-in invitee: gives their own birth data if needed, then the comparison is made. */ export function AcceptInvite({ token, hasOwnChart }: { token: string; hasOwnChart: boolean }) { const router = useRouter(); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const [needsChart, setNeedsChart] = useState(!hasOwnChart); async function accept() { setBusy(true); setError(null); try { const s = await api<{ id: string }>("/invites/accept", { body: { token } }); router.push(`/osszevetesek/${s.id}`); router.refresh(); } catch (e) { setError(errorText(e)); setBusy(false); } } if (needsChart) { return (

Add meg a születési adataidat: ebből készül a képleted, és ezt vetjük össze.

{ setNeedsChart(false); accept(); }} /> {error && (

{error}

)}
); } return (

A saját képleteddel vetjük össze.

{error && (

{error}

)}
); }