From 8aeefccc3b06a8ce4fbfa9820f9db9e6279c40b4 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 7 May 2026 09:40:58 +0200 Subject: [PATCH] feat(FalukantService, FamilyView): enhance marriage satisfaction handling - Added logic to initialize marriage satisfaction to 100 for newly married couples in the FalukantService. - Updated the FamilyView component to conditionally display marriage satisfaction only for married relationships, improving clarity in the UI. - Ensured default values are used when marriage satisfaction is not explicitly set, enhancing user experience. --- backend/services/falukantService.js | 23 ++++++++++++++++++---- frontend/src/views/falukant/FamilyView.vue | 4 ++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 2c8825f..d5d56af 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -634,6 +634,15 @@ class FalukantService extends BaseService { exclusiveFlag: false, }; + if (typeTr === 'married') { + return { + ...base, + // Nach der Hochzeit soll die Ehe mit voller Zufriedenheit starten. + marriageSatisfaction: 100, + marriagePublicStability: 100, + }; + } + if (typeTr === 'lover') { return { ...base, @@ -3693,8 +3702,10 @@ class FalukantService extends BaseService { children.sort((a, b) => new Date(a._createdAt) - new Date(b._createdAt)); const inProgress = ['wooing', 'engaged', 'married']; const activeRelationships = relationships.filter(r => inProgress.includes(r.relationshipType)); - const activeMarriage = activeRelationships.find(r => r.relationshipType === 'married') || activeRelationships[0] || null; - const marriageSatisfaction = activeMarriage?.state?.marriageSatisfaction ?? null; + const activeMarriage = activeRelationships.find(r => r.relationshipType === 'married') || null; + const marriageSatisfaction = activeMarriage + ? (activeMarriage?.state?.marriageSatisfaction ?? 100) + : null; const marriageState = this.getMarriageStateLabel(marriageSatisfaction); const userHouse = await UserHouse.findOne({ where: { userId: user.id }, @@ -3759,8 +3770,12 @@ class FalukantService extends BaseService { const family = { relationships: activeRelationships.map((r) => ({ ...r, - marriageSatisfaction: r.state?.marriageSatisfaction ?? null, - marriageState: this.getMarriageStateLabel(r.state?.marriageSatisfaction ?? null), + marriageSatisfaction: r.relationshipType === 'married' + ? (r.state?.marriageSatisfaction ?? 100) + : null, + marriageState: r.relationshipType === 'married' + ? this.getMarriageStateLabel(r.state?.marriageSatisfaction ?? 100) + : null, })), marriageSatisfaction, marriageState, diff --git a/frontend/src/views/falukant/FamilyView.vue b/frontend/src/views/falukant/FamilyView.vue index 28bb889..a0d8026 100644 --- a/frontend/src/views/falukant/FamilyView.vue +++ b/frontend/src/views/falukant/FamilyView.vue @@ -110,7 +110,7 @@
{{ $t('falukant.family.spouse.status') }}
{{ $t('falukant.family.statuses.' + relationships[0].relationshipType) }}
-
+
{{ $t('falukant.family.spouse.marriageSatisfaction') }}
{{ relationships[0].marriageSatisfaction }} @@ -212,7 +212,7 @@
-
+
{{ $t('falukant.family.spouse.marriageSatisfaction') }} {{ marriageSatisfaction }}