improvement: sorts and filters updated for tasks feature.
This commit is contained in:
51
frontend/src/components/lab/tasksViewDefaults.ts
Normal file
51
frontend/src/components/lab/tasksViewDefaults.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type { LabTaskStatus, TaskSortField } from '@/types/cases';
|
||||
|
||||
export type TasksViewState = {
|
||||
search: string;
|
||||
clinicId: string;
|
||||
statusFilter: LabTaskStatus | '';
|
||||
stepCompleted: string;
|
||||
sortBy: TaskSortField;
|
||||
sortDir: 'asc' | 'desc';
|
||||
importantOnly: boolean;
|
||||
page: number;
|
||||
highlightTaskId: string | null;
|
||||
};
|
||||
|
||||
export const DEFAULT_TASKS_VIEW: TasksViewState = {
|
||||
search: '',
|
||||
clinicId: '',
|
||||
statusFilter: 'IN_PROGRESS',
|
||||
stepCompleted: '',
|
||||
sortBy: 'date',
|
||||
sortDir: 'desc',
|
||||
importantOnly: false,
|
||||
page: 1,
|
||||
highlightTaskId: null,
|
||||
};
|
||||
|
||||
export const TASK_COMPLETE_EXIT_MS = 550;
|
||||
|
||||
export function isDefaultTasksView(state: TasksViewState): boolean {
|
||||
return (
|
||||
state.search === DEFAULT_TASKS_VIEW.search &&
|
||||
state.clinicId === DEFAULT_TASKS_VIEW.clinicId &&
|
||||
state.statusFilter === DEFAULT_TASKS_VIEW.statusFilter &&
|
||||
state.stepCompleted === DEFAULT_TASKS_VIEW.stepCompleted &&
|
||||
state.sortBy === DEFAULT_TASKS_VIEW.sortBy &&
|
||||
state.sortDir === DEFAULT_TASKS_VIEW.sortDir &&
|
||||
state.importantOnly === DEFAULT_TASKS_VIEW.importantOnly &&
|
||||
state.page === DEFAULT_TASKS_VIEW.page &&
|
||||
state.highlightTaskId === DEFAULT_TASKS_VIEW.highlightTaskId
|
||||
);
|
||||
}
|
||||
|
||||
export function buildDefaultLocateParams(taskId: string, limit: number) {
|
||||
return {
|
||||
taskId,
|
||||
limit,
|
||||
sortBy: 'date' as const,
|
||||
sortDir: 'desc' as const,
|
||||
status: 'IN_PROGRESS' as const,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user