()
| 58 | } |
| 59 | |
| 60 | const acceptInvitation = async () => { |
| 61 | if (!session) { |
| 62 | router.push( |
| 63 | `/login?callbackUrl=${encodeURIComponent(window.location.href)}`, |
| 64 | ) |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | setAccepting(true) |
| 69 | setError(null) |
| 70 | |
| 71 | try { |
| 72 | const response = await fetch(`/api/invites/${token}`, { |
| 73 | method: 'POST', |
| 74 | }) |
| 75 | const data = await response.json() |
| 76 | |
| 77 | if (!response.ok) { |
| 78 | setError(data.error || 'Failed to accept invitation') |
| 79 | return |
| 80 | } |
| 81 | |
| 82 | setSuccess(true) |
| 83 | setTimeout(() => { |
| 84 | router.push(`/orgs/${data.organization.slug}`) |
| 85 | }, 2000) |
| 86 | } catch (error) { |
| 87 | setError('Failed to accept invitation') |
| 88 | } finally { |
| 89 | setAccepting(false) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | if (loading) { |
| 94 | return ( |
nothing calls this directly
no test coverage detected