Files
speckle-server/packages/frontend-2/components/error/page/ProjectAccessErrorBlock.vue
T
Kristaps Fabians Geikins 1d2a594f0a chore: upgrade TS 5.2 -> 5.7.3 & ESLint to 9.20.1 (#4032)
* chore: upgrade TS 5.2 -> 5.7.3

* vite dts fix

* lint fix

* resolutions fix

* ui comp build fix

* precommit fix?

* latest eslint version

* autoloader fix

* undo unnecessary viewer change

* eslint fixes fe2 + trying disabled type linting

* lint fixes
2025-02-20 14:18:18 +02:00

55 lines
1.5 KiB
Vue

<template>
<NuxtErrorBoundary @error="onError">
<ProjectsInviteBanner
v-if="invite"
:invite="invite"
:show-stream-name="false"
block
@processed="onProcessed"
/>
<ErrorPageGenericUnauthorizedBlock v-else resource-type="project" />
</NuxtErrorBoundary>
</template>
<script setup lang="ts">
import { waitForever, type Optional } from '@speckle/shared'
import { useQuery } from '@vue/apollo-composable'
import { projectRoute, useNavigateToHome } from '~/lib/common/helpers/route'
import { projectInviteQuery } from '~~/lib/projects/graphql/queries'
const route = useRoute()
const logger = useLogger()
const goHome = useNavigateToHome()
const token = computed(() => route.query.token as Optional<string>)
const projectId = computed(() => route.params.id as Optional<string>)
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 = async (val: { accepted: boolean }) => {
if (!import.meta.client) return
const { accepted } = val
if (accepted) {
if (projectId.value) {
window.location.href = projectRoute(projectId.value)
} else {
window.location.reload()
}
await waitForever() // to prevent UI changes while reload is happening
} else {
await goHome()
}
}
</script>