[feat] Cloud onboarding flow implementation (#5494)

* feature: cloud onboarding scaffolding

* fix: redirect unknown routes

* feature: cloud onboarding flow

* chore: code review

* test: api mock for test failing

* refactor: Centralize onboarding routing with dedicated check views

- Add UserCheckView to handle all user status routing decisions
- Add InviteCheckView to manage invite code validation flow
- Simplify auth.ts by removing async operations and extra complexity
- Update login/signup to always redirect through UserCheckView
- Remove distributed routing logic from all onboarding components
- Simplify router guards to delegate to check views
- Fix infinite redirect loops for non-whitelisted users
- Use window.location.href for final navigation to bypass router conflicts

Breaking changes:
- Removed claimInvite from auth.ts (moved to CloudClaimInviteView)
- Changed route names to use cloud- prefix consistently
- Simplified getMe() to synchronous function

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: delete unused file

* Revert "test: api mock for test failing"

This reverts commit 06ca56c05e.

* feature: API applied

* feature: survey view

* feature: signup / login view completed

* style: min-h-screen deleted

* feature: completed login flow

* feature: router view added

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Jin Yi
2025-09-15 08:36:57 +09:00
committed by GitHub
parent f1fbab6e1f
commit 59a1380f39
26 changed files with 1678 additions and 27 deletions

View File

@@ -0,0 +1,49 @@
<template>
<div />
</template>
<script setup lang="ts">
import { nextTick, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { getSurveyCompletedStatus, getUserCloudStatus } from '@/api/auth'
const router = useRouter()
const isNavigating = ref(false)
onMounted(async () => {
// Prevent multiple executions
if (isNavigating.value) {
return
}
isNavigating.value = true
// Wait for next tick to ensure component is fully mounted
await nextTick()
const cloudUserStats = await getUserCloudStatus()
const surveyStatus = await getSurveyCompletedStatus()
try {
if (!cloudUserStats) {
await router.replace({ name: 'cloud-login' })
return
}
// Check onboarding status and redirect accordingly
if (!surveyStatus) {
// User hasn't completed survey
await router.replace({ name: 'cloud-survey' })
} else if (cloudUserStats.status !== 'active') {
// User completed survey but not whitelisted
await router.replace({ name: 'cloud-waitlist' })
} else {
// User is fully onboarded - just reload the page to bypass router issues
window.location.href = '/'
}
} catch (error) {
// On error, fallback to page reload
await router.push({ name: 'cloud-login' })
}
})
</script>