43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
import { useParams, useRouter } from 'next/navigation'
|
|
|
|
export default function InvitePage() {
|
|
const params = useParams()
|
|
const router = useRouter()
|
|
const code = params.code as string
|
|
|
|
useEffect(() => {
|
|
const applyCode = async () => {
|
|
try {
|
|
const res = await fetch('/api/referral/apply', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ code }),
|
|
})
|
|
|
|
if (res.ok) {
|
|
localStorage.setItem('referral_applied', 'true')
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to apply referral:', error)
|
|
}
|
|
|
|
router.push('/')
|
|
}
|
|
|
|
applyCode()
|
|
}, [code, router])
|
|
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-celo-green to-celo-yellow">
|
|
<div className="text-center">
|
|
<div className="text-6xl mb-4">🎉</div>
|
|
<h1 className="text-3xl font-bold text-white mb-2">Welcome to PollCelo!</h1>
|
|
<p className="text-white/80">Setting up your account...</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|