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:
Lars Behrends
2025-12-30 15:58:07 +01:00
parent c6ad8a92ec
commit ea2b803534
12 changed files with 184 additions and 341 deletions

View File

@@ -138,14 +138,24 @@ const Projects: React.FC<ProjectsProps> = ({ onSelectProject }) => {
// Subscribe to auth and data updates
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);
};
const unsubAuth = authService.subscribe(setUser);
const unsubDb = dbService.subscribe(() => {
setProjects(dbService.getProjects());
});
// Initial data load
setProjects(dbService.getProjects());
setLoading(false);
// Load fresh data on mount
loadData();
return () => {
unsubAuth();