diff --git a/frontend/core/wizard/build.gradle.kts b/frontend/core/wizard/build.gradle.kts index 01c6cf1e..5195ea67 100644 --- a/frontend/core/wizard/build.gradle.kts +++ b/frontend/core/wizard/build.gradle.kts @@ -23,24 +23,30 @@ kotlin { } sourceSets { - val commonMain by getting { - dependencies { - implementation(projects.frontend.core.navigation) - implementation(projects.frontend.core.domain) - implementation(libs.kotlinx.coroutines.core) - implementation(libs.kotlinx.serialization.json) - } + + commonMain.dependencies { + implementation(projects.frontend.core.navigation) + implementation(projects.frontend.core.domain) + implementation(libs.kotlinx.coroutines.core) + implementation(libs.kotlinx.serialization.json) } - val commonTest by getting { - dependencies { - implementation(libs.kotlin.test) - } + + commonTest.dependencies { + implementation(libs.kotlin.test) } - val jvmMain by getting - val wasmJsMain by getting { - dependencies { - implementation(libs.kotlin.stdlib.wasm.js) - } + + jvmMain.dependencies { + implementation(projects.frontend.core.navigation) + implementation(projects.frontend.core.domain) } + + jvmTest.dependencies { + implementation(libs.kotlin.test) + } + + } + + sourceSets.commonTest.dependencies { + implementation(kotlin("test")) } } diff --git a/frontend/features/veranstaltung-feature/build.gradle.kts b/frontend/features/veranstaltung-feature/build.gradle.kts index 94f64507..f7d171db 100644 --- a/frontend/features/veranstaltung-feature/build.gradle.kts +++ b/frontend/features/veranstaltung-feature/build.gradle.kts @@ -30,7 +30,8 @@ kotlin { implementation(projects.frontend.core.designSystem) implementation(projects.frontend.core.network) implementation(projects.frontend.core.domain) - implementation(project(":frontend:core:wizard")) + implementation(projects.frontend.core.navigation) + implementation(projects.frontend.core.wizard) implementation(projects.core.coreDomain) implementation(projects.frontend.core.auth) implementation(projects.frontend.features.vereinFeature) diff --git a/frontend/features/veranstaltung-feature/src/jvmMain/kotlin/at/mocode/veranstaltung/feature/presentation/EventWizardViewModel.kt b/frontend/features/veranstaltung-feature/src/jvmMain/kotlin/at/mocode/veranstaltung/feature/presentation/EventWizardViewModel.kt index 92139a0f..85b4c9e3 100644 --- a/frontend/features/veranstaltung-feature/src/jvmMain/kotlin/at/mocode/veranstaltung/feature/presentation/EventWizardViewModel.kt +++ b/frontend/features/veranstaltung-feature/src/jvmMain/kotlin/at/mocode/veranstaltung/feature/presentation/EventWizardViewModel.kt @@ -7,11 +7,18 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import at.mocode.core.domain.serialization.UuidSerializer import at.mocode.frontend.core.auth.data.local.AuthTokenManager +import at.mocode.frontend.core.domain.config.WizardFeatureFlags import at.mocode.frontend.core.domain.repository.MasterdataRepository import at.mocode.frontend.core.domain.repository.MasterdataStats import at.mocode.frontend.core.domain.zns.ZnsImportProvider import at.mocode.frontend.core.domain.zns.ZnsRemoteVerein +import at.mocode.frontend.core.navigation.AppScreen import at.mocode.frontend.core.network.NetworkConfig +import at.mocode.frontend.core.wizard.runtime.WizardContext +import at.mocode.frontend.core.wizard.runtime.WizardState +import at.mocode.frontend.core.wizard.samples.DemoEventAcc +import at.mocode.frontend.core.wizard.samples.DemoEventFlow +import at.mocode.frontend.core.wizard.samples.DemoEventStep import at.mocode.frontend.features.turnier.presentation.TurnierWizardViewModel import at.mocode.frontend.features.veranstalter.domain.VeranstalterRepository import at.mocode.frontend.features.verein.domain.VereinRepository @@ -78,6 +85,9 @@ class EventWizardViewModel( var state by mutableStateOf(VeranstaltungWizardState()) private set + // --- Orchestrator-Integration (minimal, 2 Steps) --- + private var wizardState: WizardState? = null + init { checkZnsAvailability() checkStammdatenStatus() @@ -87,6 +97,12 @@ class EventWizardViewModel( if (veranstalterIdParam != null) { loadVeranstalterContext(veranstalterIdParam) } + + // Initialisiere WizardRuntime-State (hinter Feature-Flag nutzbar) + if (WizardFeatureFlags.WizardRuntimeEnabled) { + @Suppress("UNCHECKED_CAST") + wizardState = WizardState(current = (DemoEventStep.ZnsCheck as DemoEventStep), acc = DemoEventAcc()) + } } private fun loadVeranstalterContext(id: Long) { @@ -94,7 +110,7 @@ class EventWizardViewModel( val result = veranstalterRepository.getById(id) result.onSuccess { v -> setVeranstalter( - id = Uuid.random(), // Hier müsste eigentlich die Verein-UUID rein, falls vorhanden, sonst random für Neu-Anlage + id = Uuid.random(), // Hier müsste eigentlich die Vereins-UUID rein, falls vorhanden, sonst random für Neu-Anlage nummer = v.oepsNummer, name = v.name, standardOrt = v.ort, @@ -168,29 +184,75 @@ class EventWizardViewModel( } fun nextStep() { - state = state.copy( - currentStep = when (state.currentStep) { - WizardStep.ZNS_CHECK -> WizardStep.VERANSTALTER_SELECTION - WizardStep.VERANSTALTER_SELECTION -> WizardStep.ANSPRECHPERSON_MAPPING - WizardStep.ANSPRECHPERSON_MAPPING -> WizardStep.META_DATA - WizardStep.META_DATA -> WizardStep.TURNIER_ANLAGE - WizardStep.TURNIER_ANLAGE -> WizardStep.SUMMARY - WizardStep.SUMMARY -> WizardStep.SUMMARY + if (WizardFeatureFlags.WizardRuntimeEnabled && isHandledByRuntime(state.currentStep)) { + val ctx = buildWizardContext() + val currentRuntimeState = ensureWizardStateInitialized() + val next = DemoEventFlow.next(ctx, currentRuntimeState) + wizardState = next + val mapped = mapToWizardStep(next.current) + if (mapped != null) { + state = state.copy(currentStep = mapped) + return } - ) + // Fallback, sollte eigentlich nicht eintreten + } + + state = state.copy(currentStep = when (state.currentStep) { + WizardStep.ZNS_CHECK -> WizardStep.VERANSTALTER_SELECTION + WizardStep.VERANSTALTER_SELECTION -> WizardStep.ANSPRECHPERSON_MAPPING + WizardStep.ANSPRECHPERSON_MAPPING -> WizardStep.META_DATA + WizardStep.META_DATA -> WizardStep.TURNIER_ANLAGE + WizardStep.TURNIER_ANLAGE -> WizardStep.SUMMARY + WizardStep.SUMMARY -> WizardStep.SUMMARY + }) } fun previousStep() { - state = state.copy( - currentStep = when (state.currentStep) { - WizardStep.ZNS_CHECK -> WizardStep.ZNS_CHECK - WizardStep.VERANSTALTER_SELECTION -> WizardStep.ZNS_CHECK - WizardStep.ANSPRECHPERSON_MAPPING -> WizardStep.VERANSTALTER_SELECTION - WizardStep.META_DATA -> WizardStep.ANSPRECHPERSON_MAPPING - WizardStep.TURNIER_ANLAGE -> WizardStep.META_DATA - WizardStep.SUMMARY -> WizardStep.TURNIER_ANLAGE + if (WizardFeatureFlags.WizardRuntimeEnabled && isHandledByRuntime(state.currentStep)) { + val currentRuntimeState = ensureWizardStateInitialized() + val prev = DemoEventFlow.back(currentRuntimeState) + wizardState = prev + val mapped = mapToWizardStep(prev.current) + if (mapped != null) { + state = state.copy(currentStep = mapped) + return } - ) + } + + state = state.copy(currentStep = when (state.currentStep) { + WizardStep.ZNS_CHECK -> WizardStep.ZNS_CHECK + WizardStep.VERANSTALTER_SELECTION -> WizardStep.ZNS_CHECK + WizardStep.ANSPRECHPERSON_MAPPING -> WizardStep.VERANSTALTER_SELECTION + WizardStep.META_DATA -> WizardStep.ANSPRECHPERSON_MAPPING + WizardStep.TURNIER_ANLAGE -> WizardStep.META_DATA + WizardStep.SUMMARY -> WizardStep.TURNIER_ANLAGE + }) + } + + private fun buildWizardContext(): WizardContext = WizardContext( + origin = AppScreen.EventVerwaltung, // Platzhalter; kann später aus echtem Einstieg befüllt werden + role = null, + isOnline = true, + stats = state.stammdatenStats + ) + + private fun ensureWizardStateInitialized(): WizardState { + val existing = wizardState + if (existing != null) return existing + @Suppress("UNCHECKED_CAST") + val initial = WizardState(current = (DemoEventStep.ZnsCheck as DemoEventStep), acc = DemoEventAcc()) + wizardState = initial + return initial + } + + private fun isHandledByRuntime(step: WizardStep): Boolean = when (step) { + WizardStep.ZNS_CHECK, WizardStep.VERANSTALTER_SELECTION -> true + else -> false + } + + private fun mapToWizardStep(step: DemoEventStep): WizardStep? = when (step) { + DemoEventStep.ZnsCheck -> WizardStep.ZNS_CHECK + DemoEventStep.VeranstalterSelection -> WizardStep.VERANSTALTER_SELECTION } fun setVeranstalter(id: Uuid, nummer: String, name: String, standardOrt: String, logo: String?) {