import { useState, useEffect } from 'react'; import { useRouter } from 'next/router'; import Layout from '../../components/Layout'; export default function DeclineInvite() { const router = useRouter(); const { token } = router.query; const [loading, setLoading] = useState(true); const [result, setResult] = useState(null); const [error, setError] = useState(null); useEffect(() => { if (token) { handleDeclineInvitation(); } }, [token]); const handleDeclineInvitation = async () => { try { const response = await fetch('/api/invite/decline', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ token }) }); const data = await response.json(); if (response.ok) { setResult(data); } else { setError(data.error || 'Failed to decline invitation'); } } catch (err) { setError('Network error. Please try again.'); } finally { setLoading(false); } }; if (loading) { return (

Processing Response...

Please wait while we process your response.

); } return (
{result ? (
👋

Invitation Declined

You have declined the invitation to "{result.collection.name}". You can always ask the collection owner for another invitation if you change your mind.

) : (

Error Processing Response

{error}

)}
); }