MCPcopy Create free account
hub / github.com/simstudioai/sim / handleAcceptInvitation

Function handleAcceptInvitation

apps/sim/app/invite/[id]/invite.tsx:228–264  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

226 }, [session?.user, inviteId, token])
227
228 const handleAcceptInvitation = async () => {
229 if (!session?.user || !invitation) return
230 setIsAccepting(true)
231
232 try {
233 const data = await requestJson(acceptInvitationContract, {
234 params: { id: inviteId },
235 body: { token: token ?? undefined },
236 })
237
238 if (invitation.organizationId) {
239 try {
240 await client.organization.setActive({ organizationId: invitation.organizationId })
241 } catch (setActiveError) {
242 logger.warn('Failed to set active organization after accept', setActiveError)
243 }
244 }
245
246 await Promise.all([
247 queryClient.invalidateQueries({ queryKey: subscriptionKeys.all }),
248 queryClient.invalidateQueries({ queryKey: organizationKeys.all }),
249 ])
250
251 setAccepted(true)
252 setIsAccepting(false)
253
254 setTimeout(() => router.push(data.redirectPath), 1200)
255 } catch (acceptError) {
256 logger.error('Error accepting invitation:', acceptError)
257 const code =
258 acceptError instanceof ApiClientError
259 ? codeFromApiClientError(acceptError)
260 : 'network-error'
261 setError(getInviteError(code))
262 setIsAccepting(false)
263 }
264 }
265
266 const getCallbackUrl = () => {
267 const effectiveToken =

Callers 1

CredentialSetsFunction · 0.85

Calls 7

requestJsonFunction · 0.90
codeFromApiClientErrorFunction · 0.85
setErrorFunction · 0.85
getInviteErrorFunction · 0.85
errorMethod · 0.80
warnMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected