From 21292f2dbf1b3127b747ea418173ae0b43f6ee8a Mon Sep 17 00:00:00 2001 From: aegis301 Date: Sat, 31 Jan 2026 11:33:22 +0100 Subject: [PATCH 1/3] fix: location chips in table view --- web/components/patients/LocationChips.tsx | 11 ++++---- web/utils/location.ts | 31 ++++++++++++++++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/web/components/patients/LocationChips.tsx b/web/components/patients/LocationChips.tsx index 78613150..afbf6e9a 100644 --- a/web/components/patients/LocationChips.tsx +++ b/web/components/patients/LocationChips.tsx @@ -1,6 +1,6 @@ import { Chip, Tooltip } from '@helpwave/hightide' import { MapPin } from 'lucide-react' -import { formatLocationPath } from '@/utils/location' +import { formatLocationPath, getLocationDisplayParts } from '@/utils/location' import Link from 'next/link' import type { LocationType } from '@/api/gql/generated' import { useTasksTranslation } from '@/i18n/useTasksTranslation' @@ -46,6 +46,7 @@ export const LocationChips = ({ locations, disableLink = false, small = false, p const remainingCount = locations.length - 1 const remainingLocations = locations.slice(1) + const displayParts = getLocationDisplayParts(firstLocation) const chipContent = (
- {firstLocation?.title} - {firstLocation?.kind && ( - - {translation('locationType', { type: firstLocation.kind })} + {displayParts.mainText || firstLocation?.title} + {(displayParts.pillContent ?? displayParts.pillKind) && ( + + {displayParts.pillContent ?? (displayParts.pillKind ? translation('locationType', { type: displayParts.pillKind }) : null)} )}
diff --git a/web/utils/location.ts b/web/utils/location.ts index b255f18c..a42b31fa 100644 --- a/web/utils/location.ts +++ b/web/utils/location.ts @@ -1,4 +1,4 @@ -import type { LocationNodeType } from '@/api/gql/generated' +import type { LocationNodeType, LocationType } from '@/api/gql/generated' export const LOCATION_PATH_SEPARATOR = ' / ' @@ -8,6 +8,35 @@ type PartialLocationNode = { parent?: PartialLocationNode | null, } +type LocationNodeWithKind = PartialLocationNode & { kind?: LocationType } + +export type LocationDisplayParts = { + mainText: string, + pillContent: string | null, + pillKind: LocationType | null, +} + +export const getLocationDisplayParts = (location: LocationNodeWithKind | LocationNodeType | null | undefined): LocationDisplayParts => { + if (!location) return { mainText: '', pillContent: null, pillKind: null } + const fullPath = formatLocationPath(location) + const kind = 'kind' in location ? location.kind : undefined + if (kind === 'BED' && location.parent?.parent) { + return { + mainText: [location.parent.parent.title, location.parent.title].join(LOCATION_PATH_SEPARATOR), + pillContent: location.title, + pillKind: 'BED', + } + } + if (kind === 'BED' && location.parent) { + return { + mainText: location.parent.title, + pillContent: location.title, + pillKind: 'BED', + } + } + return { mainText: fullPath, pillContent: null, pillKind: kind ?? null } +} + export const buildLocationPath = (location: PartialLocationNode | LocationNodeType | null | undefined): string[] => { if (!location) return [] From 23c6a99c5cf699991571f6660f62adc2917aa94c Mon Sep 17 00:00:00 2001 From: aegis301 Date: Sat, 31 Jan 2026 12:08:50 +0100 Subject: [PATCH 2/3] update package-lock --- web/package-lock.json | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/web/package-lock.json b/web/package-lock.json index d5541fb0..e6a914ee 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -161,7 +161,6 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -953,7 +952,6 @@ "resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz", "integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==", "license": "MIT", - "peer": true, "dependencies": { "@dnd-kit/accessibility": "^3.1.1", "@dnd-kit/utilities": "^3.2.2", @@ -3913,7 +3911,6 @@ "integrity": "sha512-6TyEnHgd6SArQO8UO2OMTxshln3QMWBtPGrOCgs3wVEmQmwyuNtB10IZMfmYDE0riwNR1cu4q+pPcxMVtaG3TA==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "playwright": "1.57.0" }, @@ -4730,7 +4727,6 @@ "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.16.tgz", "integrity": "sha512-bpMGOmV4OPmif7TNMteU/Ehf/hoC0Kf98PDc0F4BZkFrEapRMEqI/V6YS0lyzwSV6PQpY1y4xxArUIfBW5LVxQ==", "license": "MIT", - "peer": true, "dependencies": { "@tanstack/query-core": "5.90.16" }, @@ -4849,7 +4845,6 @@ "integrity": "sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "csstype": "^3.2.2" } @@ -4920,7 +4915,6 @@ "integrity": "sha512-PC0PDZfJg8sP7cmKe6L3QIL8GZwU5aRvUFedqSIpw3B+QjRSUZeeITC2M5XKeMXEzL6wccN196iy3JLwKNvDVA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.48.1", "@typescript-eslint/types": "8.48.1", @@ -5230,7 +5224,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5652,7 +5645,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -6676,7 +6668,6 @@ "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -7196,7 +7187,6 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -7489,7 +7479,6 @@ "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.12.0.tgz", "integrity": "sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ==", "license": "MIT", - "peer": true, "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } @@ -7767,7 +7756,6 @@ "integrity": "sha512-zgfER9s+ftkGKUZgc0xbx8T7/HMO4AV5/YuYiFc+AtgcO5T0v8AxYYNQ+ltzuzDZgNkYJaFspm5MMYLjQzrkmw==", "devOptional": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20" }, @@ -9702,7 +9690,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", - "peer": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -9729,6 +9716,7 @@ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.1.0" } @@ -10342,7 +10330,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "nanoid": "^3.3.8", "picocolors": "^1.1.1", @@ -10427,7 +10414,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz", "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -10437,7 +10423,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -11529,7 +11514,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -11938,9 +11922,8 @@ "version": "8.18.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", - "dev": true, + "devOptional": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10.0.0" }, From 1385f9cde3a56965bb5c7fb72b05dbbbe600f753 Mon Sep 17 00:00:00 2001 From: aegis301 Date: Sat, 31 Jan 2026 12:15:00 +0100 Subject: [PATCH 3/3] fix linting --- web/utils/location.ts | 45 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/web/utils/location.ts b/web/utils/location.ts index a42b31fa..eccf4e6c 100644 --- a/web/utils/location.ts +++ b/web/utils/location.ts @@ -1,4 +1,5 @@ -import type { LocationNodeType, LocationType } from '@/api/gql/generated' +import { LocationType } from '@/api/gql/generated' +import type { LocationNodeType } from '@/api/gql/generated' export const LOCATION_PATH_SEPARATOR = ' / ' @@ -16,27 +17,6 @@ export type LocationDisplayParts = { pillKind: LocationType | null, } -export const getLocationDisplayParts = (location: LocationNodeWithKind | LocationNodeType | null | undefined): LocationDisplayParts => { - if (!location) return { mainText: '', pillContent: null, pillKind: null } - const fullPath = formatLocationPath(location) - const kind = 'kind' in location ? location.kind : undefined - if (kind === 'BED' && location.parent?.parent) { - return { - mainText: [location.parent.parent.title, location.parent.title].join(LOCATION_PATH_SEPARATOR), - pillContent: location.title, - pillKind: 'BED', - } - } - if (kind === 'BED' && location.parent) { - return { - mainText: location.parent.title, - pillContent: location.title, - pillKind: 'BED', - } - } - return { mainText: fullPath, pillContent: null, pillKind: kind ?? null } -} - export const buildLocationPath = (location: PartialLocationNode | LocationNodeType | null | undefined): string[] => { if (!location) return [] @@ -55,6 +35,27 @@ export const formatLocationPath = (location: PartialLocationNode | LocationNodeT return buildLocationPath(location).join(separator) } +export const getLocationDisplayParts = (location: LocationNodeWithKind | LocationNodeType | null | undefined): LocationDisplayParts => { + if (!location) return { mainText: '', pillContent: null, pillKind: null } + const fullPath = formatLocationPath(location) + const kind = 'kind' in location ? location.kind : undefined + if (kind === LocationType.Bed && location.parent?.parent) { + return { + mainText: [location.parent.parent.title, location.parent.title].join(LOCATION_PATH_SEPARATOR), + pillContent: location.title, + pillKind: LocationType.Bed, + } + } + if (kind === LocationType.Bed && location.parent) { + return { + mainText: location.parent.title, + pillContent: location.title, + pillKind: LocationType.Bed, + } + } + return { mainText: fullPath, pillContent: null, pillKind: kind ?? null } +} + export const buildLocationPathFromId = ( locationId: string | null | undefined, allLocations: Map