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.
This commit is contained in:
Julien Froidefond
2025-09-14 22:42:22 +02:00
parent 1597f0fea1
commit da64221407
6 changed files with 352 additions and 12 deletions

View File

@@ -0,0 +1,30 @@
import { useState, useEffect } from 'react';
import { userPreferencesService } from '@/services/user-preferences';
export function useObjectivesVisibility() {
const [showObjectives, setShowObjectives] = useState(true);
// Charger les préférences au montage
useEffect(() => {
const saved = userPreferencesService.getViewPreferences();
setShowObjectives(saved.showObjectives);
}, []);
const toggleObjectivesVisibility = () => {
setShowObjectives(prev => {
const newValue = !prev;
// Sauvegarder dans localStorage
userPreferencesService.updateViewPreferences({
showObjectives: newValue
});
return newValue;
});
};
return {
showObjectives,
toggleObjectivesVisibility
};
}