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