improvement: some new gadgets added to dashboard. some new functionality added to existed gadgets.
This commit is contained in:
54
frontend/src/components/lab/parseTasksSearchParams.ts
Normal file
54
frontend/src/components/lab/parseTasksSearchParams.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import type { LabTaskStatus, TaskSortField } from '@/types/cases';
|
||||
import type { TasksViewState } from '@/components/lab/tasksViewDefaults';
|
||||
|
||||
/** Apply Tasks tab URL query params from Today deep links. */
|
||||
export function parseTasksSearchParams(
|
||||
searchParams: URLSearchParams,
|
||||
): Partial<TasksViewState> {
|
||||
const partial: Partial<TasksViewState> = {};
|
||||
|
||||
if (searchParams.get('importantOnly') === '1') {
|
||||
partial.importantOnly = true;
|
||||
}
|
||||
if (searchParams.get('overdueOnly') === '1') {
|
||||
partial.overdueOnly = true;
|
||||
}
|
||||
if (searchParams.get('unassignedOnly') === '1') {
|
||||
partial.unassignedOnly = true;
|
||||
}
|
||||
|
||||
const status = searchParams.get('status');
|
||||
if (status === 'IN_PROGRESS' || status === 'COMPLETED') {
|
||||
partial.statusFilter = status;
|
||||
} else if (status === 'all') {
|
||||
partial.statusFilter = '';
|
||||
}
|
||||
|
||||
const prosthesisTypeCode = searchParams.get('prosthesisTypeCode')?.trim();
|
||||
if (prosthesisTypeCode) {
|
||||
partial.prosthesisTypeCode = prosthesisTypeCode;
|
||||
partial.sortBy = 'prosthesis';
|
||||
partial.sortDir = 'desc';
|
||||
}
|
||||
|
||||
const sortBy = searchParams.get('sortBy');
|
||||
if (
|
||||
sortBy === 'date' ||
|
||||
sortBy === 'status' ||
|
||||
sortBy === 'clinic' ||
|
||||
sortBy === 'patient' ||
|
||||
sortBy === 'important' ||
|
||||
sortBy === 'prosthesis' ||
|
||||
sortBy === 'taskType' ||
|
||||
sortBy === 'dueDate'
|
||||
) {
|
||||
partial.sortBy = sortBy as TaskSortField;
|
||||
}
|
||||
|
||||
const sortDir = searchParams.get('sortDir');
|
||||
if (sortDir === 'asc' || sortDir === 'desc') {
|
||||
partial.sortDir = sortDir;
|
||||
}
|
||||
|
||||
return partial;
|
||||
}
|
||||
@@ -10,6 +10,8 @@ export type TasksViewState = {
|
||||
importantOnly: boolean;
|
||||
assignedToMe: boolean;
|
||||
overdueOnly: boolean;
|
||||
unassignedOnly: boolean;
|
||||
prosthesisTypeCode: string;
|
||||
page: number;
|
||||
highlightTaskId: string | null;
|
||||
};
|
||||
@@ -24,6 +26,8 @@ export const DEFAULT_TASKS_VIEW: TasksViewState = {
|
||||
importantOnly: false,
|
||||
assignedToMe: false,
|
||||
overdueOnly: false,
|
||||
unassignedOnly: false,
|
||||
prosthesisTypeCode: '',
|
||||
page: 1,
|
||||
highlightTaskId: null,
|
||||
};
|
||||
@@ -41,6 +45,8 @@ export function isDefaultTasksView(state: TasksViewState): boolean {
|
||||
state.importantOnly === DEFAULT_TASKS_VIEW.importantOnly &&
|
||||
state.assignedToMe === DEFAULT_TASKS_VIEW.assignedToMe &&
|
||||
state.overdueOnly === DEFAULT_TASKS_VIEW.overdueOnly &&
|
||||
state.unassignedOnly === DEFAULT_TASKS_VIEW.unassignedOnly &&
|
||||
state.prosthesisTypeCode === DEFAULT_TASKS_VIEW.prosthesisTypeCode &&
|
||||
state.page === DEFAULT_TASKS_VIEW.page &&
|
||||
state.highlightTaskId === DEFAULT_TASKS_VIEW.highlightTaskId
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user