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:
28
frontend/src/composables/setupState.js
Normal file
28
frontend/src/composables/setupState.js
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user