diff --git a/web/components/patients/PatientDetailView.tsx b/web/components/patients/PatientDetailView.tsx index c0d6ef5a..852d9bad 100644 --- a/web/components/patients/PatientDetailView.tsx +++ b/web/components/patients/PatientDetailView.tsx @@ -874,7 +874,7 @@ export const PatientDetailView = ({ return ( {() => ( -
+
{patient.state !== PatientState.Admitted && ( - - - - +
+
+ + + + + + +
diff --git a/web/components/tasks/TaskList.tsx b/web/components/tasks/TaskList.tsx index a3b3aebb..965828d9 100644 --- a/web/components/tasks/TaskList.tsx +++ b/web/components/tasks/TaskList.tsx @@ -1,7 +1,7 @@ import { useMemo, useState, forwardRef, useImperativeHandle, useEffect } from 'react' -import { Avatar, Button, Checkbox, CheckboxUncontrolled, FillerRowElement, SearchBar, Table, Tooltip } from '@helpwave/hightide' -import { PlusIcon, Table as TableIcon, LayoutGrid } from 'lucide-react' -import { useCompleteTaskMutation, useReopenTaskMutation } from '@/api/gql/generated' +import { Avatar, Button, Checkbox, CheckboxUncontrolled, ConfirmDialog, Dialog, FillerRowElement, SearchBar, Select, SelectOption, Table, Tooltip } from '@helpwave/hightide' +import { PlusIcon, Table as TableIcon, LayoutGrid, UserCheck } from 'lucide-react' +import { useAssignTaskMutation, useCompleteTaskMutation, useGetUsersQuery, useReopenTaskMutation } from '@/api/gql/generated' import clsx from 'clsx' import { SmartDate } from '@/utils/date' import { SidePanel } from '@/components/layout/SidePanel' @@ -68,15 +68,23 @@ const STORAGE_KEY_SHOW_DONE = 'task-show-done' export const TaskList = forwardRef(({ tasks: initialTasks, onRefetch, showAssignee = false, initialTaskId, onInitialTaskOpened }, ref) => { const translation = useTasksTranslation() - const { totalPatientsCount } = useTasksContext() + const { totalPatientsCount, user } = useTasksContext() const { viewType, toggleView } = useTaskViewToggle() const { mutate: completeTask } = useCompleteTaskMutation({ onSuccess: onRefetch }) const { mutate: reopenTask } = useReopenTaskMutation({ onSuccess: onRefetch }) + const { mutate: assignTask } = useAssignTaskMutation({ onSuccess: onRefetch }) + const { data: usersData } = useGetUsersQuery(undefined, { + refetchInterval: 15000, + refetchOnWindowFocus: true, + }) const [selectedPatientId, setSelectedPatientId] = useState(null) const [taskDialogState, setTaskDialogState] = useState({ isOpen: false }) const [searchQuery, setSearchQuery] = useState('') const [openedTaskId, setOpenedTaskId] = useState(null) + const [isHandoverDialogOpen, setIsHandoverDialogOpen] = useState(false) + const [selectedUserId, setSelectedUserId] = useState(null) + const [isConfirmDialogOpen, setIsConfirmDialogOpen] = useState(false) const [showDone, setShowDone] = useState(() => { if (typeof window !== 'undefined') { const stored = localStorage.getItem(STORAGE_KEY_SHOW_DONE) @@ -149,6 +157,40 @@ export const TaskList = forwardRef(({ tasks: initial }) }, [initialTasks, searchQuery, showDone]) + const openTasks = useMemo(() => { + return initialTasks.filter(t => !t.done && t.assignee?.id === user?.id) + }, [initialTasks, user?.id]) + + const users = useMemo(() => { + return usersData?.users?.filter(u => u.id !== user?.id) || [] + }, [usersData, user?.id]) + + const canHandover = openTasks.length > 0 && users.length > 0 + + const handleHandoverClick = () => { + if (!canHandover) { + return + } + setIsHandoverDialogOpen(true) + } + + const handleUserSelect = (userId: string) => { + setSelectedUserId(userId) + setIsHandoverDialogOpen(false) + setIsConfirmDialogOpen(true) + } + + const handleConfirmHandover = () => { + if (!selectedUserId) return + + openTasks.forEach(task => { + assignTask({ id: task.id, userId: selectedUserId }) + }) + + setIsConfirmDialogOpen(false) + setSelectedUserId(null) + } + const columns = useMemo[]>( () => { const cols: ColumnDef[] = [ @@ -298,7 +340,7 @@ export const TaskList = forwardRef(({ tasks: initial return (
-
+
(({ tasks: initial onSearch={() => null} />
-
-
- - {translation('showDone') || 'Show done'} +
+
+
+ + {translation('showDone') || 'Show done'} +
+
+ + + + + + +
- + {canHandover && ( - - - - + )}
) }) diff --git a/web/i18n/translations.ts b/web/i18n/translations.ts index 7cdf376b..52a29035 100644 --- a/web/i18n/translations.ts +++ b/web/i18n/translations.ts @@ -35,6 +35,8 @@ export type TasksTranslationEntries = { 'collapseAll': string, 'confirm': string, 'confirmSelection': string, + 'confirmShiftHandover': string, + 'confirmShiftHandoverDescription': string, 'create': string, 'createdAt': string, 'createTask': string, @@ -172,6 +174,8 @@ export type TasksTranslationEntries = { 'settings': string, 'settingsDescription': string, 'sex': string, + 'shiftHandover': string, + 'shiftHandoverDescription': string, 'showDone': string, 'sPropertySubjectType': (values: { subject: string }) => string, 'sPropertyType': (values: { type: string }) => string, @@ -232,6 +236,8 @@ export const tasksTranslation: Translation { return TranslationGen.resolveSelect(subject, { @@ -544,6 +552,8 @@ export const tasksTranslation: Translation { return TranslationGen.resolveSelect(subject, { diff --git a/web/locales/de-DE.arb b/web/locales/de-DE.arb index 1976b2b9..2f79930d 100644 --- a/web/locales/de-DE.arb +++ b/web/locales/de-DE.arb @@ -363,5 +363,9 @@ "noNotifications": "Keine aktuellen Updates", "notifications": "Benachrichtigungen", "dismissAll": "Alle verwerfen", - "security": "Sicherheit" + "security": "Sicherheit", + "shiftHandover": "Schichtübergabe", + "shiftHandoverDescription": "Wählen Sie einen Benutzer aus, um alle Ihnen zugewiesenen offenen Aufgaben zu übertragen.", + "confirmShiftHandover": "Schichtübergabe bestätigen", + "confirmShiftHandoverDescription": "Sind Sie sicher, dass Sie alle offenen Aufgaben an den ausgewählten Benutzer übertragen möchten?" } diff --git a/web/locales/en-US.arb b/web/locales/en-US.arb index 6d31fb11..44d68683 100644 --- a/web/locales/en-US.arb +++ b/web/locales/en-US.arb @@ -364,5 +364,9 @@ "noNotifications": "No recent updates", "notifications": "Notifications", "dismissAll": "Dismiss All", - "security": "Security" + "security": "Security", + "shiftHandover": "Shift Handover", + "shiftHandoverDescription": "Select a user to transfer all open tasks assigned to you.", + "confirmShiftHandover": "Confirm Shift Handover", + "confirmShiftHandoverDescription": "Are you sure you want to transfer all open tasks to the selected user?" }