diff --git a/backend/controllers/navigationController.js b/backend/controllers/navigationController.js index fc1d774..16e5317 100644 --- a/backend/controllers/navigationController.js +++ b/backend/controllers/navigationController.js @@ -117,10 +117,6 @@ const menuStructure = { visible: ["hasfalukantaccount"], path: "/falukant/branch" }, - directors: { - visible: ["hasfalukantaccount"], - path: "/falukant/directors" - }, family: { visible: ["hasfalukantaccount"], path: "/falukant/family" diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index bfe9c73..3bad0a5 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -1160,23 +1160,45 @@ class FalukantService extends BaseService { { model: FalukantCharacter, as: 'character', - attributes: ['firstName', 'lastName', 'birthdate', 'titleOfNobility', 'gender'], + // Wichtige Felder explizit auswählen, damit die Joins auf Titel, + // Namen und Region im äußeren Select funktionieren. + attributes: ['id', 'birthdate', 'gender', 'titleOfNobility', 'firstName', 'lastName', 'regionId'], where: { regionId: branch.regionId, }, include: [ { model: TitleOfNobility, - as: 'nobleTitle' + as: 'nobleTitle', + attributes: ['labelTr', 'level'] }, { model: FalukantPredefineFirstname, - as: 'definedFirstName' + as: 'definedFirstName', + attributes: ['name'] }, { model: FalukantPredefineLastname, - as: 'definedLastName' + as: 'definedLastName', + attributes: ['name'] }, + { + model: Knowledge, + as: 'knowledges', + attributes: ['productId', 'knowledge'], + include: [ + { + model: ProductType, + as: 'productType', + attributes: ['labelTr'], + }, + ], + }, + { + model: RegionData, + as: 'region', + attributes: ['name'] + } ] }, ], @@ -1185,6 +1207,16 @@ class FalukantService extends BaseService { return null; } const age = Math.floor((Date.now() - new Date(director.character.birthdate)) / (24 * 60 * 60 * 1000)); + + // wishedIncome analog zu getAllDirectors() berechnen + const knowledges = director.character.knowledges || []; + const avgKnowledge = knowledges.length + ? knowledges.reduce((sum, k) => sum + k.knowledge, 0) / knowledges.length + : 0; + const wishedIncome = Math.round( + director.character.nobleTitle.level * Math.pow(1.231, avgKnowledge / 1.5) + ); + return { director: { id: director.id, @@ -1193,12 +1225,18 @@ class FalukantService extends BaseService { title: director.character.nobleTitle.labelTr, age, gender: director.character.gender, + nobleTitle: director.character.nobleTitle, + definedFirstName: director.character.definedFirstName, + definedLastName: director.character.definedLastName, + knowledges: director.character.knowledges, }, income: director.income, satisfaction: director.satisfaction, mayProduce: director.mayProduce, maySell: director.maySell, mayStartTransport: director.mayStartTransport, + region: director.character.region?.name || null, + wishedIncome, }, }; } diff --git a/frontend/src/components/falukant/DirectorInfo.vue b/frontend/src/components/falukant/DirectorInfo.vue index 42a7685..e37147f 100644 --- a/frontend/src/components/falukant/DirectorInfo.vue +++ b/frontend/src/components/falukant/DirectorInfo.vue @@ -1,48 +1,119 @@