feat(FalukantService, FamilyView): enhance marriage satisfaction handling
All checks were successful
Deploy to production / deploy (push) Successful in 1m56s

- 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.
This commit is contained in:
Torsten Schulz (local)
2026-05-07 09:40:58 +02:00
parent 2c453a4a6b
commit 8aeefccc3b
2 changed files with 21 additions and 6 deletions

View File

@@ -634,6 +634,15 @@ class FalukantService extends BaseService {
exclusiveFlag: false, exclusiveFlag: false,
}; };
if (typeTr === 'married') {
return {
...base,
// Nach der Hochzeit soll die Ehe mit voller Zufriedenheit starten.
marriageSatisfaction: 100,
marriagePublicStability: 100,
};
}
if (typeTr === 'lover') { if (typeTr === 'lover') {
return { return {
...base, ...base,
@@ -3693,8 +3702,10 @@ class FalukantService extends BaseService {
children.sort((a, b) => new Date(a._createdAt) - new Date(b._createdAt)); children.sort((a, b) => new Date(a._createdAt) - new Date(b._createdAt));
const inProgress = ['wooing', 'engaged', 'married']; const inProgress = ['wooing', 'engaged', 'married'];
const activeRelationships = relationships.filter(r => inProgress.includes(r.relationshipType)); const activeRelationships = relationships.filter(r => inProgress.includes(r.relationshipType));
const activeMarriage = activeRelationships.find(r => r.relationshipType === 'married') || activeRelationships[0] || null; const activeMarriage = activeRelationships.find(r => r.relationshipType === 'married') || null;
const marriageSatisfaction = activeMarriage?.state?.marriageSatisfaction ?? null; const marriageSatisfaction = activeMarriage
? (activeMarriage?.state?.marriageSatisfaction ?? 100)
: null;
const marriageState = this.getMarriageStateLabel(marriageSatisfaction); const marriageState = this.getMarriageStateLabel(marriageSatisfaction);
const userHouse = await UserHouse.findOne({ const userHouse = await UserHouse.findOne({
where: { userId: user.id }, where: { userId: user.id },
@@ -3759,8 +3770,12 @@ class FalukantService extends BaseService {
const family = { const family = {
relationships: activeRelationships.map((r) => ({ relationships: activeRelationships.map((r) => ({
...r, ...r,
marriageSatisfaction: r.state?.marriageSatisfaction ?? null, marriageSatisfaction: r.relationshipType === 'married'
marriageState: this.getMarriageStateLabel(r.state?.marriageSatisfaction ?? null), ? (r.state?.marriageSatisfaction ?? 100)
: null,
marriageState: r.relationshipType === 'married'
? this.getMarriageStateLabel(r.state?.marriageSatisfaction ?? 100)
: null,
})), })),
marriageSatisfaction, marriageSatisfaction,
marriageState, marriageState,

View File

@@ -110,7 +110,7 @@
<dt>{{ $t('falukant.family.spouse.status') }}</dt> <dt>{{ $t('falukant.family.spouse.status') }}</dt>
<dd>{{ $t('falukant.family.statuses.' + relationships[0].relationshipType) }}</dd> <dd>{{ $t('falukant.family.statuses.' + relationships[0].relationshipType) }}</dd>
</div> </div>
<div v-if="relationships[0].marriageSatisfaction != null"> <div v-if="relationships[0].relationshipType === 'married' && relationships[0].marriageSatisfaction != null">
<dt>{{ $t('falukant.family.spouse.marriageSatisfaction') }}</dt> <dt>{{ $t('falukant.family.spouse.marriageSatisfaction') }}</dt>
<dd> <dd>
{{ relationships[0].marriageSatisfaction }} {{ relationships[0].marriageSatisfaction }}
@@ -212,7 +212,7 @@
</div> </div>
<section v-if="marriageSatisfaction != null || householdTension" class="marriage-overview surface-card"> <section v-if="marriageSatisfaction != null || householdTension" class="marriage-overview surface-card">
<div class="marriage-overview__item" v-if="marriageSatisfaction != null"> <div class="marriage-overview__item" v-if="relationships.length > 0 && relationships[0].relationshipType === 'married' && marriageSatisfaction != null">
<span class="marriage-overview__label">{{ $t('falukant.family.spouse.marriageSatisfaction') }}</span> <span class="marriage-overview__label">{{ $t('falukant.family.spouse.marriageSatisfaction') }}</span>
<strong>{{ marriageSatisfaction }}</strong> <strong>{{ marriageSatisfaction }}</strong>
</div> </div>