- 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.
31 lines
766 B
TypeScript
31 lines
766 B
TypeScript
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
|
|
};
|
|
}
|