mirror of
https://github.com/ceratic/project_vollidioten_website.git
synced 2026-05-14 00:16:47 +02:00
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:
@@ -24,16 +24,32 @@ const CityProfile: React.FC = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load city data
|
||||
const cityData = dbService.getOrg(id);
|
||||
if (cityData) {
|
||||
setCity(cityData);
|
||||
} else {
|
||||
navigate('/cities');
|
||||
return;
|
||||
}
|
||||
// Fetch fresh data from database on mount/reload
|
||||
const loadCityData = async () => {
|
||||
try {
|
||||
await dbService.fetchAll();
|
||||
const cityData = dbService.getOrg(id);
|
||||
if (cityData) {
|
||||
setCity(cityData);
|
||||
} else {
|
||||
navigate('/cities');
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to fetch fresh city data:', error);
|
||||
// Fallback to cached data
|
||||
const cityData = dbService.getOrg(id);
|
||||
if (cityData) {
|
||||
setCity(cityData);
|
||||
} else {
|
||||
navigate('/cities');
|
||||
return;
|
||||
}
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
setLoading(false);
|
||||
loadCityData();
|
||||
}, [id, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -42,7 +58,7 @@ const CityProfile: React.FC = () => {
|
||||
const loadCityData = () => {
|
||||
// Load residents (players in this city)
|
||||
const allPlayers = dbService.getPlayers();
|
||||
const cityResidents = allPlayers.filter(p => p.stats.organizationId === city.id);
|
||||
const cityResidents = allPlayers.filter(p => p.organizationId === city.id);
|
||||
setResidents(cityResidents);
|
||||
|
||||
// Load ventures (projects in this city)
|
||||
|
||||
Reference in New Issue
Block a user