feat: extend task management with new statuses and centralized configuration
- Added `cancelled` and `freeze` statuses to `TasksResponse`, `HomePageClientProps`, and `useTasks` for comprehensive task tracking. - Updated task forms to dynamically load statuses using `getAllStatuses`, enhancing maintainability and reducing hardcoded values. - Refactored Kanban components to utilize centralized status configuration, improving consistency across the application. - Adjusted visibility toggle and swimlanes to reflect new status options, ensuring a seamless user experience.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { TaskStatus } from '@/lib/types';
|
||||
import { userPreferencesService } from '@/services/user-preferences';
|
||||
import { getAllStatuses } from '@/lib/status-config';
|
||||
|
||||
export function useColumnVisibility() {
|
||||
const [hiddenStatuses, setHiddenStatuses] = useState<Set<TaskStatus>>(new Set());
|
||||
@@ -37,10 +38,15 @@ export function useColumnVisibility() {
|
||||
return !hiddenStatuses.has(status);
|
||||
};
|
||||
|
||||
const getAllAvailableStatuses = () => {
|
||||
return getAllStatuses();
|
||||
};
|
||||
|
||||
return {
|
||||
hiddenStatuses,
|
||||
toggleStatusVisibility,
|
||||
getVisibleStatuses,
|
||||
isStatusVisible
|
||||
isStatusVisible,
|
||||
getAllAvailableStatuses
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ interface UseTasksState {
|
||||
completed: number;
|
||||
inProgress: number;
|
||||
todo: number;
|
||||
cancelled: number;
|
||||
freeze: number;
|
||||
completionRate: number;
|
||||
};
|
||||
loading: boolean;
|
||||
@@ -41,6 +43,8 @@ export function useTasks(
|
||||
completed: 0,
|
||||
inProgress: 0,
|
||||
todo: 0,
|
||||
cancelled: 0,
|
||||
freeze: 0,
|
||||
completionRate: 0
|
||||
},
|
||||
loading: false,
|
||||
@@ -147,6 +151,8 @@ export function useTasks(
|
||||
completed: updatedTasks.filter(t => t.status === 'done').length,
|
||||
inProgress: updatedTasks.filter(t => t.status === 'in_progress').length,
|
||||
todo: updatedTasks.filter(t => t.status === 'todo').length,
|
||||
cancelled: updatedTasks.filter(t => t.status === 'cancelled').length,
|
||||
freeze: updatedTasks.filter(t => t.status === 'freeze').length,
|
||||
completionRate: updatedTasks.length > 0
|
||||
? Math.round((updatedTasks.filter(t => t.status === 'done').length / updatedTasks.length) * 100)
|
||||
: 0
|
||||
@@ -188,6 +194,8 @@ export function useTasks(
|
||||
completed: currentTasks.filter(t => t.status === 'done').length,
|
||||
inProgress: currentTasks.filter(t => t.status === 'in_progress').length,
|
||||
todo: currentTasks.filter(t => t.status === 'todo').length,
|
||||
cancelled: currentTasks.filter(t => t.status === 'cancelled').length,
|
||||
freeze: currentTasks.filter(t => t.status === 'freeze').length,
|
||||
completionRate: currentTasks.length > 0
|
||||
? Math.round((currentTasks.filter(t => t.status === 'done').length / currentTasks.length) * 100)
|
||||
: 0
|
||||
|
||||
Reference in New Issue
Block a user