Files
speckle-server/packages/frontend-2/components/error/page/ProjectInviteBanner.vue
T
Kristaps Fabians Geikins 95184b6883 chore(server): marking all old (non-FE2) GQL schema fields as deprecated (#2435)
* some fe2 copy changes + everything upp to automate deprecated

* blobstorage & comments & branches/commits

* all core assets reviewed

* server invites

* webhooks

* minor copy update

* updating copy
2024-07-08 14:09:55 +02:00

46 lines
1.3 KiB
Vue

<template>
<NuxtErrorBoundary @error="onError">
<ProjectsInviteBanner
v-if="invite"
:invite="invite"
:show-project-name="false"
:auto-accept="shouldAutoAcceptInvite"
@processed="onProcessed"
/>
</NuxtErrorBoundary>
</template>
<script setup lang="ts">
import type { Optional } from '@speckle/shared'
import { useQuery } from '@vue/apollo-composable'
import { projectRoute } from '~~/lib/common/helpers/route'
import { projectInviteQuery } from '~~/lib/projects/graphql/queries'
const route = useRoute()
const logger = useLogger()
const token = computed(() => route.query.token as Optional<string>)
const projectId = computed(() => route.params.id as Optional<string>)
const shouldAutoAcceptInvite = computed(() => route.query.accept === 'true')
const { result } = useQuery(
projectInviteQuery,
() => ({
projectId: projectId.value || '',
token: token.value
}),
() => ({ enabled: !!projectId.value })
)
const invite = computed(() => result.value?.projectInvite)
const onError = (err: unknown) => logger.error(err)
const onProcessed = (val: { accepted: boolean }) => {
const { accepted } = val
if (accepted && projectId.value && import.meta.client) {
window.location.href = projectRoute(projectId.value)
}
}
</script>