@@ -33,6 +33,7 @@ import { ref, watch, onMounted, nextTick } from 'vue'
3333import { useRouter } from ' vue-router'
3434import { useI18n } from ' vue-i18n'
3535import { useSetupStore } from ' ../store/setup'
36+ import StartStep from ' ./wizard/StartStep.vue'
3637import LanguageStep from ' ./wizard/LanguageStep.vue'
3738import AdminStep from ' ./wizard/AdminStep.vue'
3839import BackupStep from ' ./wizard/BackupStep.vue'
@@ -45,6 +46,7 @@ const router = useRouter()
4546const { t, locale } = useI18n ()
4647
4748const steps = [
49+ { key: ' start' , component: StartStep },
4850 { key: ' language' , component: LanguageStep },
4951 { key: ' admin' , component: AdminStep },
5052 { key: ' backup' , component: BackupStep },
@@ -55,11 +57,18 @@ const steps = [
5557
5658const currentStep = ref (1 )
5759const submitting = ref (false )
58- const form = ref ({})
60+ const form = ref ({ orgName: ' ' , language: ' de ' , demoMode: false })
5961
6062// react to language changes in the store
63+ // keep i18n in sync with the store
6164watch (() => store .language , (v ) => { if (v ) locale .value = v })
6265
66+ // When the user changes language in the wizard form, apply it immediately
67+ watch (() => form .value .language , (newLang ) => {
68+ if (! newLang ) return
69+ try { store .setLanguage (newLang ); locale .value = newLang } catch (e ) {}
70+ })
71+
6372function prevStep() {
6473 if (currentStep .value > 1 ) currentStep .value --
6574}
@@ -71,9 +80,27 @@ async function nextStep() {
7180 }
7281 // finish: persist and redirect
7382 submitting .value = true
74- store .setSetupCompleted (true )
75- // store persists to localStorage in the action; also ensure i18n locale set
76- if (store .language ) locale .value = store .language
83+ try {
84+ // persist orgName, language and demoMode
85+ const payload = {
86+ orgName: (form .value && (form .value as any ).orgName ) || store .orgName || ' ' ,
87+ language: (form .value && (form .value as any ).language ) || store .language || ' de' ,
88+ demoMode: !! ((form .value && (form .value as any ).demoMode ) || store .demoMode )
89+ }
90+ // complete() persists the whole setup to localStorage
91+ if (typeof store .complete === ' function' ) {
92+ // call the complete action
93+ // @ts-ignore
94+ store .complete (payload )
95+ } else {
96+ // fallback to existing setters
97+ try { store .setLanguage (payload .language ) } catch (e ) {}
98+ }
99+ // ensure i18n locale reflects the persisted language
100+ try { locale .value = payload .language } catch (e ) {}
101+ } catch (e ) {
102+ // swallow persistence errors
103+ }
77104 submitting .value = false
78105 // navigate to dashboard
79106 await router .push ({ name: ' Dashboard' })
0 commit comments