From 2eaa01b34e6ac14d212021431d14bd314d247d74 Mon Sep 17 00:00:00 2001 From: DasProffi Date: Mon, 26 Aug 2024 18:17:41 +0200 Subject: [PATCH] feat: add user and organization service and wrap services --- tasks/components/cards/TaskCard.tsx | 5 +- tasks/components/layout/PatientDetails.tsx | 4 +- tasks/components/layout/PatientList.tsx | 9 +- tasks/components/layout/TaskDetailView.tsx | 19 +- tasks/components/selects/TaskStatusSelect.tsx | 10 +- tasks/mutations/bed_mutations.ts | 16 +- .../mutations/offline/services/bed_service.ts | 35 ++- .../offline/services/organization_service.tsx | 232 ++++++++++++++++++ .../offline/services/patient_service.ts | 3 + .../offline/services/task_service.ts | 157 ++++++------ .../offline/services/user_service.ts | 114 +++++++++ .../offline/services/ward_service.ts | 8 +- tasks/mutations/offline/value_store.ts | 28 ++- .../organization_member_mutations.ts | 4 +- tasks/mutations/organization_mutations.ts | 28 +-- tasks/mutations/patient_mutations.ts | 31 +-- .../mutations/property/property_mutations.ts | 12 +- .../property/property_value_mutations.ts | 6 +- tasks/mutations/room_mutations.ts | 12 +- tasks/mutations/task_mutations.ts | 46 ++-- tasks/mutations/task_template_mutations.ts | 28 +-- tasks/mutations/user_mutations.ts | 4 +- tasks/mutations/ward_mutations.ts | 14 +- tasks/utils/grpc.ts | 68 +++-- 24 files changed, 658 insertions(+), 235 deletions(-) create mode 100644 tasks/mutations/offline/services/organization_service.tsx create mode 100644 tasks/mutations/offline/services/user_service.ts diff --git a/tasks/components/cards/TaskCard.tsx b/tasks/components/cards/TaskCard.tsx index 146dc113..56be2a1a 100644 --- a/tasks/components/cards/TaskCard.tsx +++ b/tasks/components/cards/TaskCard.tsx @@ -3,12 +3,11 @@ import { Card, type CardProps } from '@helpwave/common/components/Card' import { ProgressIndicator } from '@helpwave/common/components/ProgressIndicator' import { Span } from '@helpwave/common/components/Span' import { LockIcon } from 'lucide-react' -import { TaskStatus } from '@helpwave/proto-ts/services/task_svc/v1/task_svc_pb' import type { Languages } from '@helpwave/common/hooks/useLanguage' import { useTranslation, type PropsForTranslation } from '@helpwave/common/hooks/useTranslation' import { Avatar } from '@helpwave/common/components/Avatar' -import type { TaskDTO } from '@/mutations/task_mutations' import { useUserQuery } from '@/mutations/user_mutations' +import type { TaskDTO } from '@/mutations/types/task' type TaskCardTranslation = { assigned: string @@ -38,7 +37,7 @@ export const TaskCard = ({ }: PropsForTranslation) => { const translation = useTranslation(defaultTaskCardTranslations, overwriteTranslation) const progress = task.subtasks.length === 0 ? 1 : task.subtasks.filter(value => value.isDone).length / task.subtasks.length - const isOverDue = task.dueDate && task.dueDate < new Date() && task.status !== TaskStatus.TASK_STATUS_DONE + const isOverDue = task.dueDate && task.dueDate < new Date() && task.status !== 'done' const { data: assignee } = useUserQuery(task.assignee) diff --git a/tasks/components/layout/PatientDetails.tsx b/tasks/components/layout/PatientDetails.tsx index 7d542641..898991c5 100644 --- a/tasks/components/layout/PatientDetails.tsx +++ b/tasks/components/layout/PatientDetails.tsx @@ -7,7 +7,6 @@ import { Textarea } from '@helpwave/common/components/user-input/Textarea' import { ToggleableInput } from '@helpwave/common/components/user-input/ToggleableInput' import useSaveDelay from '@helpwave/common/hooks/useSaveDelay' import { LoadingAndErrorComponent } from '@helpwave/common/components/LoadingAndErrorComponent' -import { TaskStatus } from '@helpwave/proto-ts/services/task_svc/v1/task_svc_pb' import { ColumnTitle } from '../ColumnTitle' import { TasksKanbanBoard } from './TasksKanbanBoard' import { WardOverviewContext } from '@/pages/ward/[wardId]' @@ -24,6 +23,7 @@ import { PatientDischargeModal } from '@/components/modals/PatientDischargeModal import { TaskDetailModal } from '@/components/modals/TaskDetailModal' import { RoomBedSelect } from '@/components/selects/RoomBedSelect' import { PropertyList } from '@/components/layout/property/PropertyList' +import type { TaskStatus } from '@/mutations/types/task' type PatientDetailTranslation = { patientDetails: string, @@ -208,7 +208,7 @@ export const PatientDetail = ({ patientId={newPatient.id} editedTaskId={taskId} onEditTask={task => { - setInitialTaskStatus(task.status === TaskStatus.TASK_STATUS_DONE ? TaskStatus.TASK_STATUS_TODO : task.status) + setInitialTaskStatus(task.status === 'done' ? 'todo' : task.status) setTaskId(task.id) }} /> diff --git a/tasks/components/layout/PatientList.tsx b/tasks/components/layout/PatientList.tsx index cf5eadc7..b7c344b0 100644 --- a/tasks/components/layout/PatientList.tsx +++ b/tasks/components/layout/PatientList.tsx @@ -38,7 +38,8 @@ type PatientListTranslation = { deleteDescriptionText: string, addPatient: string, search: string, - bed: string + bed: string, + otherWard: string } const defaultPatientListTranslations: Record = { @@ -56,6 +57,7 @@ const defaultPatientListTranslations: Record addPatient: 'Add Patient', search: 'Search', bed: 'Bed', + otherWard: 'Other Ward', }, de: { patients: 'Patienten', @@ -71,6 +73,7 @@ const defaultPatientListTranslations: Record addPatient: 'Patient hinzufügen', search: 'Suchen', bed: 'Bett', + otherWard: 'Andere Station', } } @@ -120,7 +123,9 @@ export const PatientList = ({ const [dischargingPatient, setDischargingPatient] = useState() const [deletePatient, setDeletePatient] = useState() - const activeLabelText = (patient: PatientWithBedAndRoomDTO) => `${patient.room.name} - ${patient.bed.name}` + const activeLabelText = (patient: PatientWithBedAndRoomDTO) => patient.room.wardId === wardId + ? `${patient.room.name} - ${patient.bed.name}` + : translation.otherWard const filteredActive = !data ? [] : MultiSearchWithMapping(search, data.active, value => [value.name, activeLabelText(value)]) const filteredUnassigned = !data ? [] : SimpleSearchWithMapping(search, data.unassigned, value => value.name) diff --git a/tasks/components/layout/TaskDetailView.tsx b/tasks/components/layout/TaskDetailView.tsx index fddd7a2c..14ee155e 100644 --- a/tasks/components/layout/TaskDetailView.tsx +++ b/tasks/components/layout/TaskDetailView.tsx @@ -15,7 +15,6 @@ import { LoadingAndErrorComponent } from '@helpwave/common/components/LoadingAnd import { ConfirmDialog } from '@helpwave/common/components/modals/ConfirmDialog' import { ModalHeader } from '@helpwave/common/components/modals/Modal' import { formatDateTime } from '@helpwave/common/util/date' -import { TaskStatus } from '@helpwave/proto-ts/services/task_svc/v1/task_svc_pb' import { TaskTemplateListColumn } from '../TaskTemplateListColumn' import { SubtaskView } from '../SubtaskView' import { TaskVisibilitySelect } from '@/components/selects/TaskVisibilitySelect' @@ -27,7 +26,6 @@ import { } from '@/mutations/task_template_mutations' import { useAuth } from '@/hooks/useAuth' import { - emptyTask, useAssignTaskToUserMutation, useSubTaskAddMutation, useTaskCreateMutation, @@ -37,11 +35,12 @@ import { useTaskToInProgressMutation, useTaskToToDoMutation, useTaskUpdateMutation, - useUnassignTaskToUserMutation, - type TaskDTO + useUnassignTaskToUserMutation } from '@/mutations/task_mutations' import { type WardWithOrganizationIdDTO, useWardQuery } from '@/mutations/ward_mutations' import { AssigneeSelect } from '@/components/selects/AssigneeSelect' +import type { TaskDTO, TaskStatus } from '@/mutations/types/task' +import { emptyTask } from '@/mutations/types/task' type TaskDetailViewTranslation = { close: string, @@ -224,17 +223,17 @@ const TaskDetailViewSidebar = ({ { if (!isCreating) { switch (status) { - case TaskStatus.TASK_STATUS_TODO: + case 'todo': toToDoMutation.mutate(task.id) break - case TaskStatus.TASK_STATUS_IN_PROGRESS: + case 'inProgress': toInProgressMutation.mutate(task.id) break - case TaskStatus.TASK_STATUS_DONE: + case 'done': toDoneMutation.mutate(task.id) break default: @@ -322,7 +321,7 @@ export const TaskDetailView = ({ const [task, setTask] = useState({ ...emptyTask, - status: initialStatus ?? TaskStatus.TASK_STATUS_TODO + status: initialStatus ?? 'todo' }) const addSubtaskMutation = useSubTaskAddMutation(taskId) @@ -375,7 +374,7 @@ export const TaskDetailView = ({ - {task.status !== TaskStatus.TASK_STATUS_DONE && ( + {task.status !== 'done' && (