First-run setup wizard (/setup)

- setup_complete site setting; a fresh admin is steered to /setup until it is
  finished (skippable for the session).
- SetupWizard.vue: Site (facility/base-url/access-domain), Features (plugin
  enable/disable), Floor Map dimensions, Starter Data (seed common vendors),
  Finish. Reuses the settings + plugins APIs.
- setup blueprint: POST /setup/seed-starter (idempotent common vendors) and
  POST /setup/complete. setupState composable drives the router redirect.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-07-10 07:47:01 -04:00
parent ec2de635ed
commit 843b225a47
8 changed files with 379 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
// Tracks whether first-run setup is complete, so the app can steer a fresh
// admin into the /setup wizard. Defaults to "complete" so the wizard never
// flashes before the real value loads.
import { ref } from 'vue'
import { settingsApi } from '../api'
export const setupComplete = ref(true)
// Session-only: a fresh admin who clicks "Skip for now" is not nagged again
// until the next login/reload.
export const setupSkipped = ref(false)
const loaded = ref(false)
export function isSetupLoaded() {
return loaded.value
}
export async function refreshSetupState() {
try {
const response = await settingsApi.get('setup_complete')
const value = response.data?.data?.value
setupComplete.value = value === true || value === 'true'
} catch (err) {
// If we cannot read it, assume complete so we do not trap the user.
setupComplete.value = true
}
loaded.value = true
return setupComplete.value
}