From f555d04073c068ebb8f72b69bf605fce59cb4413 Mon Sep 17 00:00:00 2001 From: DasProffi <67233923+DasProffi@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:10:57 +0200 Subject: [PATCH] fix: fix translation of unscheduled in German --- api-services/types/tasks/task.ts | 21 ++++ tasks/components/KanbanColumn.tsx | 2 +- tasks/components/PillLabel.tsx | 139 +++++++++++++++++++++ tasks/components/cards/PatientCard.tsx | 2 +- tasks/components/cards/WardCard.tsx | 2 +- tasks/components/pill/PillLabel.tsx | 63 ---------- tasks/components/pill/PillLabelBox.tsx | 59 --------- tasks/components/pill/PillLabelsColumn.tsx | 23 ---- 8 files changed, 163 insertions(+), 148 deletions(-) create mode 100644 tasks/components/PillLabel.tsx delete mode 100644 tasks/components/pill/PillLabel.tsx delete mode 100644 tasks/components/pill/PillLabelBox.tsx delete mode 100644 tasks/components/pill/PillLabelsColumn.tsx diff --git a/api-services/types/tasks/task.ts b/api-services/types/tasks/task.ts index 750b1d78e..7bd4c71e6 100644 --- a/api-services/types/tasks/task.ts +++ b/api-services/types/tasks/task.ts @@ -1,3 +1,5 @@ +import type { Translation } from '@helpwave/hightide' + export type SubTaskDTO = { id: string, name: string, @@ -10,6 +12,25 @@ export type CreateSubTaskDTO = SubTaskDTO & { export type TaskStatus = 'done' | 'inProgress' | 'todo' +export type TaskStatusTranslation = Record + +const translation: Translation = { + en: { + done: 'Done', + inProgress: 'In Progress', + todo: 'Todo', + }, + de: { + done: 'Fertig', + inProgress: 'In Arbeit', + todo: 'Todo', + } +} + +export const TaskStatusUtil = { + translation +} + export type TaskDTO = { id: string, name: string, diff --git a/tasks/components/KanbanColumn.tsx b/tasks/components/KanbanColumn.tsx index 369b0db24..020f156a8 100644 --- a/tasks/components/KanbanColumn.tsx +++ b/tasks/components/KanbanColumn.tsx @@ -8,7 +8,7 @@ import type { TaskDTO, TaskStatus } from '@helpwave/api-services/types/tasks/tas import { emptyTask } from '@helpwave/api-services/types/tasks/task' import { Sortable } from './dnd-kit/Sortable' import { TaskCard } from './cards/TaskCard' -import { PillLabel } from './pill/PillLabel' +import { PillLabel } from './PillLabel' type KanbanColumnsTranslation = { addTask: string, diff --git a/tasks/components/PillLabel.tsx b/tasks/components/PillLabel.tsx new file mode 100644 index 000000000..ee830ece0 --- /dev/null +++ b/tasks/components/PillLabel.tsx @@ -0,0 +1,139 @@ +import clsx from 'clsx' +import type { Translation } from '@helpwave/hightide' +import { type PropsForTranslation, useTranslation } from '@helpwave/hightide' +import type { TaskStatus, TaskStatusTranslation } from '@helpwave/api-services/types/tasks/task' +import { TaskStatusUtil } from '@helpwave/api-services/types/tasks/task' + +// +// PillLabel +// + +type PillLabelTranslation = TaskStatusTranslation + +const defaultPillLabelTranslation: Translation = TaskStatusUtil.translation + +const mapping = { + todo: { + mainClassName: 'bg-tag-red-background text-tag-red-text', + iconClassName: 'bg-tag-red-icon', + }, + inProgress: { + mainClassName: 'bg-tag-yellow-background text-tag-yellow-text', + iconClassName: 'bg-tag-yellow-icon', + }, + done: { + mainClassName: 'bg-tag-green-background text-tag-green-text', + iconClassName: 'bg-tag-green-icon', + }, +} as const + +export type PillLabelProps = { + count?: number, + taskStatus?: TaskStatus, +} + +/** + * A Label for showing a TaskState's information like the state name and the count of Tasks in this state + */ +export const PillLabel = ({ + overwriteTranslation, + count, + taskStatus = 'todo' + }: PropsForTranslation) => { + const state = mapping[taskStatus] + const translation = useTranslation(defaultPillLabelTranslation, overwriteTranslation) + + return ( +
+
+
+ {translation[taskStatus]} +
+ {count ?? '-'} +
+ ) +} + +// +// PillLabelsColumn +// + +export type PillLabelsColumnProps = { + unscheduledCount?: number, + inProgressCount?: number, + doneCount?: number, +} + +/** + * A column showing the all TaskStates with a PillLabel for each + */ +export const PillLabelsColumn = ({ unscheduledCount, inProgressCount, doneCount }: PillLabelsColumnProps) => { + return ( +
+ + + +
+ ) +} + +// +// PillLabelBox +// + +export type PillLabelBoxProps = { + unscheduled: number, + inProgress: number, + done: number, +} + +/** + * A Label for showing all TaskState information like the state name and the count of all Tasks in this state. + * + * For each state unscheduled, in progress and done there will be a number + */ +export const PillLabelBox = ({ unscheduled, inProgress, done }: PillLabelBoxProps) => { + const between = '0.25rem' + const height = '0.75rem' + const borderStyle = { + borderTopWidth: height, + borderBottomWidth: height, + borderLeftWidth: between, + borderRightWidth: between, + } + return ( +
+
+
+ {unscheduled} +
+
+
+
+
+ {inProgress} +
+
+
+
+
+ {done} +
+
+ ) +} diff --git a/tasks/components/cards/PatientCard.tsx b/tasks/components/cards/PatientCard.tsx index c91cf1bf9..11d9f880f 100644 --- a/tasks/components/cards/PatientCard.tsx +++ b/tasks/components/cards/PatientCard.tsx @@ -1,7 +1,7 @@ import type { Translation } from '@helpwave/hightide' import { useTranslation, type PropsForTranslation } from '@helpwave/hightide' -import { PillLabelsColumn } from '../pill/PillLabelsColumn' +import { PillLabelsColumn } from '../PillLabel' import { DragCard, type DragCardProps } from './DragCard' import clsx from 'clsx' diff --git a/tasks/components/cards/WardCard.tsx b/tasks/components/cards/WardCard.tsx index 300be2f19..7d9ee2ed2 100644 --- a/tasks/components/cards/WardCard.tsx +++ b/tasks/components/cards/WardCard.tsx @@ -1,7 +1,7 @@ import clsx from 'clsx' import { Bed } from 'lucide-react' import type { WardOverviewDTO } from '@helpwave/api-services/types/tasks/wards' -import { PillLabelBox } from '../pill/PillLabelBox' +import { PillLabelBox } from '../PillLabel' import { EditCard, type EditCardProps } from './EditCard' export type WardCardProps = EditCardProps & { diff --git a/tasks/components/pill/PillLabel.tsx b/tasks/components/pill/PillLabel.tsx deleted file mode 100644 index b38f15d31..000000000 --- a/tasks/components/pill/PillLabel.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import clsx from 'clsx' -import { useTranslation, type PropsForTranslation } from '@helpwave/hightide' -import type { TaskStatus } from '@helpwave/api-services/types/tasks/task' - -type PillLabelTranslation = { - text: string, -} - - -const mapping = { - todo: { - mainClassName: 'bg-tag-red-background text-tag-red-text', - iconClassName: 'bg-tag-red-icon', - translation: { - en: { text: 'unscheduled' }, - de: { text: 'Nicht Geplant' } - } - }, - inProgress: { - mainClassName: 'bg-tag-yellow-background text-tag-yellow-text', - iconClassName: 'bg-tag-yellow-icon', - translation: { - en: { text: 'in progress' }, - de: { text: 'In Arbeit' } - } - }, - done: { - mainClassName: 'bg-tag-green-background text-tag-green-text', - iconClassName: 'bg-tag-green-icon', - translation: { - en: { text: 'done' }, - de: { text: 'Fertig' } - } - }, -} as const - -export type PillLabelProps = { - count?: number, - taskStatus?: TaskStatus, -} - -/** - * A Label for showing a TaskState's information like the state name and the count of Tasks in this state - */ -const PillLabel = ({ - overwriteTranslation, - count, - taskStatus = 'todo' -}: PropsForTranslation) => { - const state = mapping[taskStatus] - const translation = useTranslation(state.translation, overwriteTranslation) - return ( -
-
-
- {translation.text} -
- {count ?? '-'} -
- ) -} - -export { PillLabel } diff --git a/tasks/components/pill/PillLabelBox.tsx b/tasks/components/pill/PillLabelBox.tsx deleted file mode 100644 index bdaabb53a..000000000 --- a/tasks/components/pill/PillLabelBox.tsx +++ /dev/null @@ -1,59 +0,0 @@ - - -export type PillLabelBoxProps = { - unscheduled: number, - inProgress: number, - done: number, -} - -/** - * A Label for showing all TaskState information like the state name and the count of all Tasks in this state. - * - * For each state unscheduled, in progress and done there will be a number - */ -const PillLabelBox = ({ unscheduled, inProgress, done }: PillLabelBoxProps) => { - const between = '3.2px' - const height = '12px' // equivalent to 1.5rem / 2 = 24px / 2 = h-6 / 2 of tailwind - const borderStyle = { - borderTopWidth: height, - borderBottomWidth: height, - borderLeftWidth: between, - borderRightWidth: between, - } - return ( -
-
-
- {unscheduled} -
-
-
-
-
- {inProgress} -
-
-
-
-
- {done} -
-
- ) -} - -export { PillLabelBox } diff --git a/tasks/components/pill/PillLabelsColumn.tsx b/tasks/components/pill/PillLabelsColumn.tsx deleted file mode 100644 index 65ac2c006..000000000 --- a/tasks/components/pill/PillLabelsColumn.tsx +++ /dev/null @@ -1,23 +0,0 @@ - -import { PillLabel } from './PillLabel' - -export type PillLabelsColumnProps = { - unscheduledCount?: number, - inProgressCount?: number, - doneCount?: number, -} - -/** - * A column showing the all TaskStates with a PillLabel for each - */ -const PillLabelsColumn = ({ unscheduledCount, inProgressCount, doneCount }: PillLabelsColumnProps) => { - return ( -
- - - -
- ) -} - -export { PillLabelsColumn }