feat: reintroduce TaskStats to HomePageClient and TasksProvider

- Added `initialStats` prop to `HomePageClient` and `TasksProvider` to enhance task management capabilities.
- Updated data fetching in `page.tsx` to include task statistics, improving overall functionality.
- Adjusted `useTasks` hook to utilize the new `stats` parameter, ensuring comprehensive task data handling.
This commit is contained in:
Julien Froidefond
2025-09-19 09:05:11 +02:00
parent e0b1090f18
commit b7707d7651
3 changed files with 11 additions and 6 deletions

View File

@@ -8,10 +8,11 @@ export const dynamic = 'force-dynamic';
export default async function HomePage() {
// SSR - Récupération des données côté serveur
const [initialTasks, initialTags, initialPreferences] = await Promise.all([
const [initialTasks, initialTags, initialPreferences, initialStats] = await Promise.all([
tasksService.getTasks(),
tagsService.getTags(),
userPreferencesService.getAllPreferences()
userPreferencesService.getAllPreferences(),
tasksService.getTaskStats()
]);
return (
@@ -19,6 +20,7 @@ export default async function HomePage() {
initialTasks={initialTasks}
initialTags={initialTags}
initialPreferences={initialPreferences}
initialStats={initialStats}
/>
);
}

View File

@@ -38,12 +38,13 @@ interface TasksProviderProps {
children: ReactNode;
initialTasks: Task[];
initialTags?: (Tag & { usage: number })[];
initialStats?: TaskStats;
}
export function TasksProvider({ children, initialTasks, initialTags }: TasksProviderProps) {
export function TasksProvider({ children, initialTasks, initialTags, initialStats }: TasksProviderProps) {
const tasksState = useTasks(
{ limit: 20 },
{ tasks: initialTasks }
{ tasks: initialTasks, stats: initialStats }
);
const { tags, loading: tagsLoading, error: tagsError } = useTags(initialTags);