Refactor CityProfile and PlayerProfile components for improved data fetching and error handling; add NPC management modals for banner, gallery, and logo with enhanced user experience and error feedback.

This commit is contained in:
Lars Behrends
2025-12-30 13:56:00 +01:00
parent 5eb2eca110
commit c6ad8a92ec
14 changed files with 2539 additions and 102 deletions

View File

@@ -78,6 +78,26 @@ class DatabaseService {
return this.players.find(p => p.uuid === uuid);
}
// Fetch individual player data directly from API (for profile pages)
async fetchPlayer(uuid: string): Promise<Player | null> {
try {
const response = await fetch(`${API_URL}/players/${uuid}`);
if (response.ok) {
const playerData = await response.json();
// Update local cache
this.players = this.players.map(p => p.uuid === uuid ? playerData : p);
if (!this.players.find(p => p.uuid === uuid)) {
this.players.push(playerData);
}
this.notify();
return playerData;
}
} catch (e) {
console.warn("Failed to fetch individual player data", e);
}
return null;
}
getOrg(id: string): Organization | undefined {
return this.orgs.find(o => o.id === id);
}