From da64221407a555889223678b4aea9a61e214a767 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Sun, 14 Sep 2025 22:42:22 +0200 Subject: [PATCH] feat: refactor ObjectivesBoard and enhance column visibility management - Replaced local state management in `ObjectivesBoard` with `useObjectivesCollapse` hook for better state handling. - Updated collapse button logic to use the new hook's toggle function, improving code clarity. - Refactored `useColumnVisibility` to load user preferences on mount and persist visibility changes, enhancing user experience. - Integrated user preferences for Kanban filters in `TasksContext`, allowing for persistent filter settings across sessions. --- components/kanban/ObjectivesBoard.tsx | 8 +- hooks/useColumnVisibility.ts | 21 ++- hooks/useObjectivesCollapse.ts | 39 +++++ hooks/useObjectivesVisibility.ts | 30 ++++ services/user-preferences.ts | 224 ++++++++++++++++++++++++++ src/contexts/TasksContext.tsx | 42 ++++- 6 files changed, 352 insertions(+), 12 deletions(-) create mode 100644 hooks/useObjectivesCollapse.ts create mode 100644 hooks/useObjectivesVisibility.ts create mode 100644 services/user-preferences.ts diff --git a/components/kanban/ObjectivesBoard.tsx b/components/kanban/ObjectivesBoard.tsx index cfdf147..8419337 100644 --- a/components/kanban/ObjectivesBoard.tsx +++ b/components/kanban/ObjectivesBoard.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState } from 'react'; +import { useObjectivesCollapse } from '@/hooks/useObjectivesCollapse'; import { Task } from '@/lib/types'; import { TaskCard } from './TaskCard'; import { Card, CardHeader, CardContent } from '@/components/ui/Card'; @@ -23,7 +23,7 @@ export function ObjectivesBoard({ compactView = false, pinnedTagName = "Objectifs" }: ObjectivesBoardProps) { - const [isCollapsed, setIsCollapsed] = useState(false); + const { isCollapsed, toggleCollapse } = useObjectivesCollapse(); if (tasks.length === 0) { return null; // Ne rien afficher s'il n'y a pas d'objectifs @@ -36,7 +36,7 @@ export function ObjectivesBoard({