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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user