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:
@@ -3,7 +3,7 @@
|
|||||||
import { Header } from '@/components/ui/Header';
|
import { Header } from '@/components/ui/Header';
|
||||||
import { TasksProvider, useTasksContext } from '@/contexts/TasksContext';
|
import { TasksProvider, useTasksContext } from '@/contexts/TasksContext';
|
||||||
import { UserPreferencesProvider } from '@/contexts/UserPreferencesContext';
|
import { UserPreferencesProvider } from '@/contexts/UserPreferencesContext';
|
||||||
import { Task, Tag, UserPreferences } from '@/lib/types';
|
import { Task, Tag, UserPreferences, TaskStats } from '@/lib/types';
|
||||||
import { CreateTaskData } from '@/clients/tasks-client';
|
import { CreateTaskData } from '@/clients/tasks-client';
|
||||||
import { DashboardStats } from '@/components/dashboard/DashboardStats';
|
import { DashboardStats } from '@/components/dashboard/DashboardStats';
|
||||||
import { QuickActions } from '@/components/dashboard/QuickActions';
|
import { QuickActions } from '@/components/dashboard/QuickActions';
|
||||||
@@ -14,6 +14,7 @@ interface HomePageClientProps {
|
|||||||
initialTasks: Task[];
|
initialTasks: Task[];
|
||||||
initialTags: (Tag & { usage: number })[];
|
initialTags: (Tag & { usage: number })[];
|
||||||
initialPreferences: UserPreferences;
|
initialPreferences: UserPreferences;
|
||||||
|
initialStats: TaskStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -50,12 +51,13 @@ function HomePageContent() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HomePageClient({ initialTasks, initialTags, initialPreferences }: HomePageClientProps) {
|
export function HomePageClient({ initialTasks, initialTags, initialPreferences, initialStats }: HomePageClientProps) {
|
||||||
return (
|
return (
|
||||||
<UserPreferencesProvider initialPreferences={initialPreferences}>
|
<UserPreferencesProvider initialPreferences={initialPreferences}>
|
||||||
<TasksProvider
|
<TasksProvider
|
||||||
initialTasks={initialTasks}
|
initialTasks={initialTasks}
|
||||||
initialTags={initialTags}
|
initialTags={initialTags}
|
||||||
|
initialStats={initialStats}
|
||||||
>
|
>
|
||||||
<HomePageContent />
|
<HomePageContent />
|
||||||
</TasksProvider>
|
</TasksProvider>
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ export const dynamic = 'force-dynamic';
|
|||||||
|
|
||||||
export default async function HomePage() {
|
export default async function HomePage() {
|
||||||
// SSR - Récupération des données côté serveur
|
// 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(),
|
tasksService.getTasks(),
|
||||||
tagsService.getTags(),
|
tagsService.getTags(),
|
||||||
userPreferencesService.getAllPreferences()
|
userPreferencesService.getAllPreferences(),
|
||||||
|
tasksService.getTaskStats()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -19,6 +20,7 @@ export default async function HomePage() {
|
|||||||
initialTasks={initialTasks}
|
initialTasks={initialTasks}
|
||||||
initialTags={initialTags}
|
initialTags={initialTags}
|
||||||
initialPreferences={initialPreferences}
|
initialPreferences={initialPreferences}
|
||||||
|
initialStats={initialStats}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,12 +38,13 @@ interface TasksProviderProps {
|
|||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
initialTasks: Task[];
|
initialTasks: Task[];
|
||||||
initialTags?: (Tag & { usage: number })[];
|
initialTags?: (Tag & { usage: number })[];
|
||||||
|
initialStats?: TaskStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TasksProvider({ children, initialTasks, initialTags }: TasksProviderProps) {
|
export function TasksProvider({ children, initialTasks, initialTags, initialStats }: TasksProviderProps) {
|
||||||
const tasksState = useTasks(
|
const tasksState = useTasks(
|
||||||
{ limit: 20 },
|
{ limit: 20 },
|
||||||
{ tasks: initialTasks }
|
{ tasks: initialTasks, stats: initialStats }
|
||||||
);
|
);
|
||||||
|
|
||||||
const { tags, loading: tagsLoading, error: tagsError } = useTags(initialTags);
|
const { tags, loading: tagsLoading, error: tagsError } = useTags(initialTags);
|
||||||
|
|||||||
Reference in New Issue
Block a user