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:
30
hooks/useObjectivesVisibility.ts
Normal file
30
hooks/useObjectivesVisibility.ts
Normal 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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user