Refactor character creation and heir fetching logic in FalukantService and OverviewView

- Updated character creation process to utilize transactions for improved data integrity during heir generation.
- Enhanced heir fetching logic in OverviewView to check for both mainBranchRegion.id and mainBranchRegionId, adding error handling for missing regions.
- Added warnings for empty heir responses from the API to improve debugging and user feedback.
This commit is contained in:
Torsten Schulz (local)
2026-01-07 11:20:03 +01:00
parent 75dbd78da1
commit d42e1da14b
2 changed files with 72 additions and 48 deletions

View File

@@ -339,13 +339,23 @@ export default {
return new Date(timestamp).toLocaleString();
},
async fetchPotentialHeirs() {
if (!this.falukantUser?.mainBranchRegion?.id) return;
// Prüfe sowohl mainBranchRegion.id als auch mainBranchRegionId
const regionId = this.falukantUser?.mainBranchRegion?.id || this.falukantUser?.mainBranchRegionId;
if (!regionId) {
console.error('No main branch region found', this.falukantUser);
this.potentialHeirs = [];
return;
}
this.loadingHeirs = true;
try {
const response = await apiClient.get('/api/falukant/heirs/potential');
this.potentialHeirs = response.data || [];
if (this.potentialHeirs.length === 0) {
console.warn('No potential heirs returned from API');
}
} catch (error) {
console.error('Error fetching potential heirs:', error);
console.error('Error details:', error.response?.data || error.message);
this.potentialHeirs = [];
} finally {
this.loadingHeirs = false;