Files
speckle-server/packages/frontend-2/lib/projects/composables/invites.ts
T
Kristaps Fabians Geikins ee5ae8af62 fix(fe2): accept invite before onboarding after sign up (#2491)
* explicitly ordering global middlewares

* various subscription fixes & WIP project invite middleware

* SSR invite accept & toast notifs seem to work

* backend support for mixpanel

* mixpanel be logic -> shared

* minor fix

* finissh

* lint fix

* minor comment adjustments

* better adblock handling
2024-07-11 11:45:11 +03:00

45 lines
956 B
TypeScript

import { useMixpanel } from '~/lib/core/composables/mp'
import { useProcessProjectInvite } from '~/lib/projects/composables/projectManagement'
export const useProjectInviteManager = () => {
const processInvite = useProcessProjectInvite()
const mp = useMixpanel()
const loading = ref(false)
const useInvite = async (params: {
accept: boolean
token: string
projectId: string
inviteId?: string
}) => {
const { token, accept, projectId, inviteId } = params
if (!token?.length || !projectId?.length) return false
loading.value = true
const success = await processInvite(
{
projectId,
accept,
token
},
{ inviteId }
)
loading.value = false
if (!success) return false
mp.track('Invite Action', {
type: 'project invite',
accepted: accept
})
return !!success
}
return {
useInvite,
loading: computed(() => loading.value)
}
}