mirror of
https://github.com/ceratic/project_vollidioten_website.git
synced 2026-05-14 00:16:47 +02:00
feat: implement Players component with data fetching and loading state; remove mock data and enhance error handling in database service
This commit is contained in:
@@ -48,19 +48,26 @@ const Dashboard: React.FC = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const loadData = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await dbService.fetchAll();
|
||||
} catch (error) {
|
||||
console.warn('Failed to fetch fresh data:', error);
|
||||
// Continue with cached data
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
// Subscribe to database updates
|
||||
const unsubscribe = dbService.subscribe(() => {
|
||||
setPlayers(dbService.getPlayers());
|
||||
setProjects(dbService.getProjects());
|
||||
setOrgs(dbService.getOrgs());
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
// Initial data load
|
||||
setPlayers(dbService.getPlayers());
|
||||
setProjects(dbService.getProjects());
|
||||
setOrgs(dbService.getOrgs());
|
||||
setLoading(false);
|
||||
// Load fresh data on mount
|
||||
loadData();
|
||||
|
||||
return unsubscribe;
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user