@kenyaemr/esm-bed-management-app 1.0.1-pre.7 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +36 -0
- package/README.md +6 -38
- package/dist/130.js +2 -0
- package/dist/{800.js.LICENSE.txt → 130.js.LICENSE.txt} +2 -0
- package/dist/130.js.map +1 -0
- package/dist/148.js +1 -0
- package/dist/148.js.map +1 -0
- package/dist/169.js +1 -0
- package/dist/169.js.map +1 -0
- package/dist/271.js +1 -0
- package/dist/319.js +1 -0
- package/dist/325.js +1 -0
- package/dist/325.js.map +1 -0
- package/dist/339.js +1 -0
- package/dist/339.js.map +1 -0
- package/dist/455.js +1 -1
- package/dist/455.js.LICENSE.txt +6 -0
- package/dist/455.js.map +1 -1
- package/dist/460.js +1 -0
- package/dist/501.js +1 -0
- package/dist/501.js.map +1 -0
- package/dist/542.js +1 -0
- package/dist/542.js.map +1 -0
- package/dist/574.js +1 -1
- package/dist/591.js +2 -0
- package/dist/{26.js.LICENSE.txt → 591.js.LICENSE.txt} +3 -3
- package/dist/591.js.map +1 -0
- package/dist/644.js +1 -0
- package/dist/757.js +1 -0
- package/dist/766.js +2 -0
- package/dist/{330.js.LICENSE.txt → 766.js.LICENSE.txt} +0 -9
- package/dist/766.js.map +1 -0
- package/dist/{294.js → 784.js} +2 -2
- package/dist/{294.js.map → 784.js.map} +1 -1
- package/dist/788.js +1 -0
- package/dist/807.js +1 -0
- package/dist/833.js +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-bed-management-app.js +1 -0
- package/dist/{esm-kenyaemr-bed-management-app.js.buildmanifest.json → openmrs-esm-bed-management-app.js.buildmanifest.json} +202 -155
- package/dist/openmrs-esm-bed-management-app.js.map +1 -0
- package/dist/routes.json +1 -1
- package/jest.config.js +3 -0
- package/package-lock.json +5893 -0
- package/package.json +25 -83
- package/src/__mocks__/react-i18next.js +18 -14
- package/src/admin-card-link.component.tsx +7 -10
- package/src/bed-administration/bed-administration-form.component.tsx +65 -99
- package/src/bed-administration/bed-administration-table.component.tsx +68 -127
- package/src/bed-administration/bed-administration-table.scss +12 -16
- package/src/bed-administration/bed-administration.resource.ts +16 -18
- package/src/bed-administration/edit-bed-form.component.tsx +20 -31
- package/src/bed-administration/new-bed-form.component.tsx +28 -44
- package/src/{bed-admission/bed-tag → bed-tag}/bed-tag-administration-table.component.tsx +35 -60
- package/src/{bed-admission/bed-tag → bed-tag}/bed-tags-admin-form.component.tsx +30 -34
- package/src/{bed-admission/bed-tag → bed-tag}/edit-tag-form.component.tsx +17 -25
- package/src/{bed-admission/bed-tag → bed-tag}/new-tag-form.component.tsx +20 -27
- package/src/{bed-admission/bed-type → bed-type}/bed-type-admin-form.component.tsx +37 -44
- package/src/{bed-admission/bed-type → bed-type}/bed-type-administration-table.component.tsx +36 -60
- package/src/{bed-admission/bed-type → bed-type}/edit-bed-type.component.tsx +17 -25
- package/src/{bed-admission/bed-type → bed-type}/new-bed-type-form.component.tsx +21 -28
- package/src/card-header/card-header.component.tsx +20 -0
- package/src/card-header/card-header.scss +45 -0
- package/src/config-schema.ts +9 -17
- package/src/declarations.d.ts +5 -5
- package/src/empty-state/empty-state.component.tsx +6 -21
- package/src/empty-state/empty-state.scss +10 -10
- package/src/header/header.component.tsx +14 -23
- package/src/header/header.scss +11 -11
- package/src/header/illustration.component.tsx +3 -3
- package/src/home.component.tsx +4 -4
- package/src/index.ts +21 -48
- package/src/left-panel/left-panel.component.tsx +7 -17
- package/src/left-panel/left-panel.scss +8 -7
- package/src/left-panel-link.component.tsx +14 -24
- package/src/root.component.tsx +12 -12
- package/src/root.scss +2 -2
- package/src/routes.json +12 -12
- package/src/setup-tests.ts +1 -1
- package/src/summary/summary.component.tsx +16 -30
- package/src/summary/summary.resource.ts +116 -95
- package/src/summary/summary.scss +31 -29
- package/src/types.ts +50 -40
- package/src/ward-card/ward-card.component.tsx +5 -12
- package/src/ward-card/ward-card.scss +2 -2
- package/src/ward-with-beds/ward-with-beds.component.tsx +28 -47
- package/src/ward-with-beds/ward-with-beds.scss +5 -5
- package/translations/am.json +51 -0
- package/translations/ar.json +51 -0
- package/translations/en.json +48 -4
- package/translations/es.json +51 -0
- package/translations/fr.json +51 -0
- package/translations/he.json +51 -0
- package/translations/km.json +51 -0
- package/translations/zh.json +51 -0
- package/translations/zh_CN.json +51 -0
- package/tsconfig.json +3 -21
- package/webpack.config.js +1 -1
- package/.editorconfig +0 -12
- package/.eslintignore +0 -2
- package/.eslintrc +0 -37
- package/.husky/pre-commit +0 -4
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.prettierignore +0 -14
- package/.turbo.json +0 -18
- package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -541
- package/.yarn/plugins/@yarnpkg/plugin-version.cjs +0 -550
- package/.yarn/versions/cb9a89ac.yml +0 -0
- package/LICENSE +0 -373
- package/dist/187.js +0 -1
- package/dist/187.js.map +0 -1
- package/dist/207.js +0 -1
- package/dist/207.js.map +0 -1
- package/dist/26.js +0 -2
- package/dist/26.js.map +0 -1
- package/dist/283.js +0 -1
- package/dist/283.js.map +0 -1
- package/dist/330.js +0 -2
- package/dist/330.js.map +0 -1
- package/dist/352.js +0 -1
- package/dist/352.js.map +0 -1
- package/dist/404.js +0 -1
- package/dist/404.js.map +0 -1
- package/dist/558.js +0 -2
- package/dist/558.js.LICENSE.txt +0 -14
- package/dist/558.js.map +0 -1
- package/dist/629.js +0 -1
- package/dist/629.js.map +0 -1
- package/dist/707.js +0 -1
- package/dist/707.js.map +0 -1
- package/dist/800.js +0 -2
- package/dist/800.js.map +0 -1
- package/dist/850.js +0 -1
- package/dist/850.js.map +0 -1
- package/dist/884.js +0 -1
- package/dist/884.js.map +0 -1
- package/dist/933.js +0 -1
- package/dist/933.js.map +0 -1
- package/dist/esm-kenyaemr-bed-management-app.js +0 -1
- package/dist/esm-kenyaemr-bed-management-app.js.map +0 -1
- package/i18next-parser.config.js +0 -89
- package/src/assets/landing-page.png +0 -0
- package/src/assets/logo.svg +0 -1
- package/src/bed-admission/active-patients/active-patients-table.component.tsx +0 -299
- package/src/bed-admission/active-patients/active-visits.resource.ts +0 -171
- package/src/bed-admission/active-patients/admission-action-button-styles.scss +0 -0
- package/src/bed-admission/active-patients/admission-action-button.component.tsx +0 -26
- package/src/bed-admission/active-patients/index.tsx +0 -15
- package/src/bed-admission/active-patients/patient-queues.resource.ts +0 -136
- package/src/bed-admission/active-patients/styles.scss +0 -284
- package/src/bed-admission/active-patients/view-action-menu.component.tsx +0 -33
- package/src/bed-admission/admitted-patients/active-admissions.resource.ts +0 -121
- package/src/bed-admission/admitted-patients/admitted-patients-table.component.tsx +0 -280
- package/src/bed-admission/admitted-patients/admitted-patients.component.tsx +0 -22
- package/src/bed-admission/admitted-patients/location-combo-box.component.tsx +0 -55
- package/src/bed-admission/admitted-patients/styles.scss +0 -284
- package/src/bed-admission/bed-admission-tabs-styles.scss +0 -30
- package/src/bed-admission/bed-admission-tabs.component.tsx +0 -69
- package/src/bed-admission/bed-admission.component.tsx +0 -15
- package/src/bed-admission/bed-admission.resource.ts +0 -35
- package/src/bed-admission/bed-layout/bed-layout-list.component.tsx +0 -101
- package/src/bed-admission/bed-layout/bed-layout.component.tsx +0 -64
- package/src/bed-admission/bed-layout/bed-layout.scss +0 -118
- package/src/bed-admission/bed-layout/min-bed-layout.component.tsx +0 -26
- package/src/bed-admission/createDashboardLink.tsx +0 -47
- package/src/bed-admission/discharged-patients/discharged-patients.componet.tsx +0 -19
- package/src/bed-admission/helpers/functions.ts +0 -102
- package/src/bed-admission/types.ts +0 -133
- package/src/workspace/allocate-bed-workspace.component.tsx +0 -141
- package/src/workspace/allocate-bed.scss +0 -117
- package/src/workspace/overlay.component.tsx +0 -55
- package/src/workspace/overlay.scss +0 -96
- /package/dist/{294.js.LICENSE.txt → 784.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,112 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kenyaemr/esm-bed-management-app",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"browser": "dist/esm-kenyaemr-bed-management-app.js",
|
|
3
|
+
"version": "8.0.2",
|
|
4
|
+
"description": "Bed management app for OpenMRS 3",
|
|
5
|
+
"browser": "dist/openmrs-esm-bed-management-app.js",
|
|
7
6
|
"main": "src/index.ts",
|
|
8
7
|
"source": true,
|
|
8
|
+
"license": "MPL-2.0",
|
|
9
|
+
"homepage": "https://github.com/openmrs/openmrs-esm-patient-management#readme",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"start": "openmrs develop",
|
|
11
12
|
"serve": "webpack serve --mode=development",
|
|
13
|
+
"debug": "npm run serve",
|
|
12
14
|
"build": "webpack --mode production",
|
|
13
|
-
"analyze": "webpack --mode=production --env
|
|
14
|
-
"lint": "
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"test": "jest --config jest.config.js --passWithNoTests",
|
|
18
|
-
"verify": "turbo lint typescript coverage",
|
|
15
|
+
"analyze": "webpack --mode=production --env.analyze=true",
|
|
16
|
+
"lint": "cross-env eslint src --ext ts,tsx",
|
|
17
|
+
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color",
|
|
18
|
+
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
|
|
19
19
|
"coverage": "yarn test --coverage",
|
|
20
|
-
"
|
|
21
|
-
"extract-translations": "i18next 'src/**/*.component.tsx' --config
|
|
22
|
-
},
|
|
23
|
-
"husky": {
|
|
24
|
-
"hooks": {
|
|
25
|
-
"pre-commit": "pretty-quick --staged && yarn verify"
|
|
26
|
-
}
|
|
20
|
+
"typescript": "tsc",
|
|
21
|
+
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.extension.tsx' 'src/**/*modal.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
|
|
27
22
|
},
|
|
28
23
|
"browserslist": [
|
|
29
24
|
"extends browserslist-config-openmrs"
|
|
30
25
|
],
|
|
31
26
|
"keywords": [
|
|
32
|
-
"openmrs"
|
|
33
|
-
"microfrontends"
|
|
27
|
+
"openmrs"
|
|
34
28
|
],
|
|
35
|
-
"repository": {
|
|
36
|
-
"type": "git",
|
|
37
|
-
"url": "git+https://github.com/mets-programme/esm-ugandaemr-bed-management-app.git"
|
|
38
|
-
},
|
|
39
|
-
"homepage": "https://github.com/mets-programme/esm-ugandaemr-bed-management-app#readme",
|
|
40
29
|
"publishConfig": {
|
|
41
30
|
"access": "public"
|
|
42
31
|
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/openmrs/openmrs-esm-patient-management.git"
|
|
35
|
+
},
|
|
43
36
|
"bugs": {
|
|
44
|
-
"url": "https://github.com/
|
|
37
|
+
"url": "https://github.com/openmrs/openmrs-esm-patient-management/issues"
|
|
45
38
|
},
|
|
46
39
|
"dependencies": {
|
|
47
|
-
"@carbon/react": "
|
|
48
|
-
"
|
|
49
|
-
"@openmrs/openmrs-form-engine-lib": "^1.0.0-pre.44",
|
|
50
|
-
"classnames": "^2.3.2",
|
|
51
|
-
"dayjs": "^1.11.9",
|
|
52
|
-
"lodash-es": "^4.17.21",
|
|
53
|
-
"react-hook-form": "^7.47.0",
|
|
54
|
-
"react-image-annotate": "^1.8.0",
|
|
55
|
-
"zod": "^3.22.2"
|
|
40
|
+
"@carbon/react": "~1.37.0",
|
|
41
|
+
"lodash-es": "^4.17.15"
|
|
56
42
|
},
|
|
57
43
|
"peerDependencies": {
|
|
58
|
-
"@openmrs/esm-framework": "
|
|
59
|
-
"
|
|
44
|
+
"@openmrs/esm-framework": "5.x",
|
|
45
|
+
"dayjs": "1.x",
|
|
60
46
|
"react": "18.x",
|
|
61
47
|
"react-i18next": "11.x",
|
|
62
48
|
"react-router-dom": "6.x",
|
|
63
|
-
"
|
|
49
|
+
"swr": "2.x"
|
|
64
50
|
},
|
|
65
51
|
"devDependencies": {
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
"@openmrs/esm-styleguide": "next",
|
|
69
|
-
"@swc/cli": "^0.1.62",
|
|
70
|
-
"@swc/core": "^1.3.68",
|
|
71
|
-
"@swc/jest": "^0.2.26",
|
|
72
|
-
"@testing-library/dom": "^8.20.1",
|
|
73
|
-
"@testing-library/jest-dom": "^5.16.5",
|
|
74
|
-
"@testing-library/react": "^13.4.0",
|
|
75
|
-
"@testing-library/user-event": "^14.4.3",
|
|
76
|
-
"@types/jest": "^28.1.8",
|
|
77
|
-
"@types/react": "^18.2.14",
|
|
78
|
-
"@types/react-dom": "^18.2.6",
|
|
79
|
-
"@types/react-router": "^5.1.20",
|
|
80
|
-
"@types/react-router-dom": "^5.3.3",
|
|
81
|
-
"@types/webpack-env": "^1.18.1",
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
83
|
-
"@typescript-eslint/parser": "^5.61.0",
|
|
84
|
-
"css-loader": "^6.8.1",
|
|
85
|
-
"eslint": "^8.44.0",
|
|
86
|
-
"eslint-config-prettier": "^8.8.0",
|
|
87
|
-
"eslint-config-ts-react-important-stuff": "^3.0.0",
|
|
88
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
89
|
-
"husky": "^8.0.0",
|
|
90
|
-
"i18next": "^23.2.8",
|
|
91
|
-
"i18next-parser": "^8.0.0",
|
|
92
|
-
"identity-obj-proxy": "^3.0.0",
|
|
93
|
-
"jest": "^28.1.3",
|
|
94
|
-
"jest-cli": "^28.1.3",
|
|
95
|
-
"jest-environment-jsdom": "^28.1.3",
|
|
96
|
-
"openmrs": "next",
|
|
97
|
-
"prettier": "^2.8.8",
|
|
98
|
-
"pretty-quick": "^3.1.3",
|
|
99
|
-
"react": "^18.2.0",
|
|
100
|
-
"react-dom": "^18.2.0",
|
|
101
|
-
"react-i18next": "^11.18.6",
|
|
102
|
-
"react-router-dom": "^6.14.1",
|
|
103
|
-
"rxjs": "^6.6.7",
|
|
104
|
-
"swc-loader": "^0.2.3",
|
|
105
|
-
"turbo": "^1.10.7",
|
|
106
|
-
"typescript": "^4.9.5",
|
|
107
|
-
"webpack": "^5.88.1",
|
|
108
|
-
"webpack-cli": "^5.1.4"
|
|
109
|
-
},
|
|
110
|
-
"packageManager": "yarn@3.6.3",
|
|
111
|
-
"stableVersion": "1.0.0"
|
|
52
|
+
"webpack": "^5.74.0"
|
|
53
|
+
}
|
|
112
54
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/** At present, this entire mock is boilerplate. */
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import 'react';
|
|
3
|
+
const reactI18next = require('react-i18next');
|
|
4
4
|
|
|
5
|
-
const hasChildren = (node) =>
|
|
6
|
-
node && (node.children || (node.props && node.props.children));
|
|
5
|
+
const hasChildren = (node) => node && (node.children || (node.props && node.props.children));
|
|
7
6
|
|
|
8
|
-
const getChildren = (node) =>
|
|
9
|
-
node && node.children ? node.children : node.props && node.props.children;
|
|
7
|
+
const getChildren = (node) => (node && node.children ? node.children : node.props && node.props.children);
|
|
10
8
|
|
|
11
9
|
const renderNodes = (reactNodes) => {
|
|
12
|
-
if (typeof reactNodes ===
|
|
10
|
+
if (typeof reactNodes === 'string') {
|
|
13
11
|
return reactNodes;
|
|
14
12
|
}
|
|
15
13
|
|
|
@@ -17,18 +15,15 @@ const renderNodes = (reactNodes) => {
|
|
|
17
15
|
const child = reactNodes[key];
|
|
18
16
|
const isElement = React.isValidElement(child);
|
|
19
17
|
|
|
20
|
-
if (typeof child ===
|
|
18
|
+
if (typeof child === 'string') {
|
|
21
19
|
return child;
|
|
22
20
|
}
|
|
23
21
|
if (hasChildren(child)) {
|
|
24
22
|
const inner = renderNodes(getChildren(child));
|
|
25
23
|
return React.cloneElement(child, { ...child.props, key: i }, inner);
|
|
26
24
|
}
|
|
27
|
-
if (typeof child ===
|
|
28
|
-
return Object.keys(child).reduce(
|
|
29
|
-
(str, childKey) => `${str}${child[childKey]}`,
|
|
30
|
-
""
|
|
31
|
-
);
|
|
25
|
+
if (typeof child === 'object' && !isElement) {
|
|
26
|
+
return Object.keys(child).reduce((str, childKey) => `${str}${child[childKey]}`, '');
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
return child;
|
|
@@ -36,7 +31,16 @@ const renderNodes = (reactNodes) => {
|
|
|
36
31
|
};
|
|
37
32
|
|
|
38
33
|
const useMock = [(k) => k, {}];
|
|
39
|
-
useMock.t = (
|
|
34
|
+
useMock.t = (key, defaultValue, options = {}) => {
|
|
35
|
+
let translatedString = defaultValue;
|
|
36
|
+
Object.keys(options).forEach((key) => {
|
|
37
|
+
if (key != 'interpolation') {
|
|
38
|
+
translatedString = defaultValue.replace(`{{${key}}}`, `${options[key]}`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return translatedString ?? key;
|
|
43
|
+
};
|
|
40
44
|
useMock.i18n = {};
|
|
41
45
|
|
|
42
46
|
module.exports = {
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { useTranslation } from
|
|
3
|
-
import { Layer, ClickableTile } from
|
|
4
|
-
import { ArrowRight } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Layer, ClickableTile } from '@carbon/react';
|
|
4
|
+
import { ArrowRight } from '@carbon/react/icons';
|
|
5
5
|
|
|
6
6
|
const BedManagementAdminCardLink: React.FC = () => {
|
|
7
7
|
const { t } = useTranslation();
|
|
8
|
-
const header = t(
|
|
8
|
+
const header = t('manageBeds', 'Manage Beds');
|
|
9
9
|
return (
|
|
10
10
|
<Layer>
|
|
11
|
-
<ClickableTile
|
|
12
|
-
href={window.getOpenmrsSpaBase() + "bed-management/summary"}
|
|
13
|
-
rel="noopener noreferrer"
|
|
14
|
-
>
|
|
11
|
+
<ClickableTile href={window.getOpenmrsSpaBase() + 'bed-management'} rel="noopener noreferrer">
|
|
15
12
|
<div>
|
|
16
13
|
<div className="heading">{header}</div>
|
|
17
|
-
<div className="content">{t(
|
|
14
|
+
<div className="content">{t('bedManagement', 'Bed Management')}</div>
|
|
18
15
|
</div>
|
|
19
16
|
<div className="iconWrapper">
|
|
20
17
|
<ArrowRight size={16} />
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import capitalize from
|
|
3
|
-
import { z } from
|
|
4
|
-
import { useForm, Controller } from
|
|
5
|
-
import { zodResolver } from
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import capitalize from 'lodash-es/capitalize';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { useForm, Controller } from 'react-hook-form';
|
|
5
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
6
6
|
import {
|
|
7
7
|
Button,
|
|
8
8
|
ComboBox,
|
|
@@ -19,18 +19,18 @@ import {
|
|
|
19
19
|
TextArea,
|
|
20
20
|
TextInput,
|
|
21
21
|
InlineNotification,
|
|
22
|
-
} from
|
|
23
|
-
import { useTranslation } from
|
|
24
|
-
import { Location } from
|
|
25
|
-
import type { BedType,
|
|
26
|
-
import { BedAdministrationData } from
|
|
22
|
+
} from '@carbon/react';
|
|
23
|
+
import { useTranslation } from 'react-i18next';
|
|
24
|
+
import { getCoreTranslation, type Location } from '@openmrs/esm-framework';
|
|
25
|
+
import type { BedType, BedFormData } from '../types';
|
|
26
|
+
import { type BedAdministrationData } from './bed-administration-types';
|
|
27
27
|
|
|
28
28
|
const numberInString = z.string().transform((val, ctx) => {
|
|
29
29
|
const parsed = parseInt(val);
|
|
30
30
|
if (isNaN(parsed) || parsed < 1) {
|
|
31
31
|
ctx.addIssue({
|
|
32
32
|
code: z.ZodIssueCode.custom,
|
|
33
|
-
message:
|
|
33
|
+
message: 'Please enter a valid number',
|
|
34
34
|
});
|
|
35
35
|
return z.NEVER;
|
|
36
36
|
}
|
|
@@ -38,19 +38,15 @@ const numberInString = z.string().transform((val, ctx) => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
const BedAdministrationSchema = z.object({
|
|
41
|
-
bedId: z.string().
|
|
41
|
+
bedId: z.string().max(255),
|
|
42
42
|
description: z.string().max(255),
|
|
43
43
|
bedRow: numberInString,
|
|
44
44
|
bedColumn: numberInString,
|
|
45
45
|
location: z
|
|
46
46
|
.object({ display: z.string(), uuid: z.string() })
|
|
47
|
-
.refine((value) => value.display !=
|
|
48
|
-
occupancyStatus: z
|
|
49
|
-
|
|
50
|
-
.refine((value) => value != "", "Please select a valid occupied status"),
|
|
51
|
-
bedType: z
|
|
52
|
-
.string()
|
|
53
|
-
.refine((value) => value != "", "Please select a valid bed type"),
|
|
47
|
+
.refine((value) => value.display != '', 'Please select a valid location'),
|
|
48
|
+
occupancyStatus: z.string().refine((value) => value != '', 'Please select a valid occupied status'),
|
|
49
|
+
bedType: z.string().refine((value) => value != '', 'Please select a valid bed type'),
|
|
54
50
|
});
|
|
55
51
|
|
|
56
52
|
interface BedAdministrationFormProps {
|
|
@@ -61,7 +57,7 @@ interface BedAdministrationFormProps {
|
|
|
61
57
|
handleCreateQuestion?: (formData: BedAdministrationData) => void;
|
|
62
58
|
headerTitle: string;
|
|
63
59
|
occupancyStatuses: string[];
|
|
64
|
-
initialData:
|
|
60
|
+
initialData: BedFormData;
|
|
65
61
|
}
|
|
66
62
|
|
|
67
63
|
interface ErrorType {
|
|
@@ -79,19 +75,13 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
79
75
|
initialData,
|
|
80
76
|
}) => {
|
|
81
77
|
const { t } = useTranslation();
|
|
82
|
-
const [occupancyStatus, setOccupancyStatus] = useState(
|
|
83
|
-
|
|
84
|
-
);
|
|
85
|
-
const [selectedBedType] = useState(initialData.bedType.name);
|
|
78
|
+
const [occupancyStatus, setOccupancyStatus] = useState(capitalize(initialData.status));
|
|
79
|
+
const [selectedBedType] = useState(initialData.bedType?.name ?? '');
|
|
86
80
|
const [showErrorNotification, setShowErrorNotification] = useState(false);
|
|
87
|
-
const [formStateError, setFormStateError] = useState(
|
|
81
|
+
const [formStateError, setFormStateError] = useState('');
|
|
88
82
|
|
|
89
83
|
const filterLocationNames = (location) => {
|
|
90
|
-
return (
|
|
91
|
-
location.item.display
|
|
92
|
-
?.toLowerCase()
|
|
93
|
-
.includes(location?.inputValue?.toLowerCase()) ?? []
|
|
94
|
-
);
|
|
84
|
+
return location.item.display?.toLowerCase().includes(location?.inputValue?.toLowerCase()) ?? [];
|
|
95
85
|
};
|
|
96
86
|
|
|
97
87
|
const {
|
|
@@ -99,16 +89,16 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
99
89
|
control,
|
|
100
90
|
formState: { isDirty },
|
|
101
91
|
} = useForm<BedAdministrationData>({
|
|
102
|
-
mode:
|
|
92
|
+
mode: 'all',
|
|
103
93
|
resolver: zodResolver(BedAdministrationSchema),
|
|
104
94
|
defaultValues: {
|
|
105
|
-
bedId: initialData.bedNumber
|
|
106
|
-
description: initialData.description
|
|
107
|
-
bedRow: initialData.row.toString()
|
|
108
|
-
bedColumn: initialData.column.toString()
|
|
109
|
-
location: initialData.location
|
|
110
|
-
occupancyStatus: capitalize(initialData.status)
|
|
111
|
-
bedType: initialData.bedType
|
|
95
|
+
bedId: initialData.bedNumber ?? '',
|
|
96
|
+
description: initialData.bedType?.description ?? '',
|
|
97
|
+
bedRow: initialData.row.toString() ?? '0',
|
|
98
|
+
bedColumn: initialData.column.toString() ?? '0',
|
|
99
|
+
location: initialData.location ?? {},
|
|
100
|
+
occupancyStatus: capitalize(initialData.status) ?? occupancyStatus,
|
|
101
|
+
bedType: initialData.bedType?.name ?? '',
|
|
112
102
|
},
|
|
113
103
|
});
|
|
114
104
|
|
|
@@ -126,16 +116,12 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
126
116
|
};
|
|
127
117
|
|
|
128
118
|
return (
|
|
129
|
-
<ComposedModal
|
|
130
|
-
open={showModal}
|
|
131
|
-
onClose={() => onModalChange(false)}
|
|
132
|
-
preventCloseOnClickOutside
|
|
133
|
-
>
|
|
119
|
+
<ComposedModal open={showModal} onClose={() => onModalChange(false)} preventCloseOnClickOutside>
|
|
134
120
|
<ModalHeader title={headerTitle} />
|
|
135
|
-
<
|
|
136
|
-
<
|
|
121
|
+
<ModalBody hasScrollingContent>
|
|
122
|
+
<Form>
|
|
137
123
|
<Stack gap={3}>
|
|
138
|
-
<FormGroup legendText={
|
|
124
|
+
<FormGroup legendText={''}>
|
|
139
125
|
<Controller
|
|
140
126
|
name="bedId"
|
|
141
127
|
control={control}
|
|
@@ -143,8 +129,8 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
143
129
|
<>
|
|
144
130
|
<TextInput
|
|
145
131
|
id="bedId"
|
|
146
|
-
labelText={t(
|
|
147
|
-
placeholder={t(
|
|
132
|
+
labelText={t('bedId', 'Bed number')}
|
|
133
|
+
placeholder={t('bedIdPlaceholder', 'e.g. BMW-201')}
|
|
148
134
|
invalidText={fieldState.error?.message}
|
|
149
135
|
{...field}
|
|
150
136
|
/>
|
|
@@ -163,12 +149,9 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
163
149
|
rows={2}
|
|
164
150
|
id="description"
|
|
165
151
|
invalidText={fieldState?.error?.message}
|
|
166
|
-
labelText={t(
|
|
152
|
+
labelText={t('description', 'Bed description')}
|
|
167
153
|
{...field}
|
|
168
|
-
placeholder={t(
|
|
169
|
-
"description",
|
|
170
|
-
"Enter the bed description"
|
|
171
|
-
)}
|
|
154
|
+
placeholder={t('description', 'Enter the bed description')}
|
|
172
155
|
/>
|
|
173
156
|
</>
|
|
174
157
|
)}
|
|
@@ -213,27 +196,21 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
213
196
|
<Controller
|
|
214
197
|
name="location"
|
|
215
198
|
control={control}
|
|
216
|
-
render={({
|
|
217
|
-
fieldState,
|
|
218
|
-
field: { onChange, onBlur, value, ref },
|
|
219
|
-
}) => (
|
|
199
|
+
render={({ fieldState, field: { onChange, onBlur, value, ref } }) => (
|
|
220
200
|
<ComboBox
|
|
221
|
-
aria-label={t(
|
|
201
|
+
aria-label={t('location', 'Location')}
|
|
222
202
|
shouldFilterItem={filterLocationNames}
|
|
223
203
|
id="location"
|
|
224
|
-
label={t(
|
|
204
|
+
label={t('location', 'Location')}
|
|
225
205
|
invalidText={fieldState?.error?.message}
|
|
226
206
|
items={allLocations}
|
|
227
207
|
onBlur={onBlur}
|
|
228
208
|
ref={ref}
|
|
229
209
|
selectedItem={value}
|
|
230
210
|
onChange={({ selectedItem }) => onChange(selectedItem)}
|
|
231
|
-
itemToString={(location) => location?.display ??
|
|
232
|
-
placeholder={t(
|
|
233
|
-
|
|
234
|
-
"Select a bed location"
|
|
235
|
-
)}
|
|
236
|
-
titleText={t("bedLocation", "Location")}
|
|
211
|
+
itemToString={(location) => location?.display ?? ''}
|
|
212
|
+
placeholder={t('selectBedLocation', 'Select a bed location')}
|
|
213
|
+
titleText={t('bedLocation', 'Location')}
|
|
237
214
|
/>
|
|
238
215
|
)}
|
|
239
216
|
/>
|
|
@@ -246,21 +223,17 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
246
223
|
render={({ field, fieldState }) => (
|
|
247
224
|
<Select
|
|
248
225
|
id="occupancyStatus"
|
|
249
|
-
labelText={t(
|
|
226
|
+
labelText={t('occupancyStatus', 'Occupied Status')}
|
|
250
227
|
invalidText={fieldState.error?.message}
|
|
251
228
|
defaultValue={occupancyStatus}
|
|
252
229
|
onChange={(event) => setOccupancyStatus(event.target.value)}
|
|
253
230
|
value={occupancyStatus}
|
|
254
|
-
{...field}
|
|
255
|
-
|
|
256
|
-
<SelectItem
|
|
257
|
-
text={t("chooseOccupiedStatus", "Choose occupied status")}
|
|
258
|
-
value=""
|
|
259
|
-
/>
|
|
231
|
+
{...field}>
|
|
232
|
+
<SelectItem text={t('chooseOccupiedStatus', 'Choose occupied status')} value="" />
|
|
260
233
|
{occupancyStatuses.map((occupancyStatus, index) => (
|
|
261
234
|
<SelectItem
|
|
262
|
-
text={t(
|
|
263
|
-
value={t(
|
|
235
|
+
text={t('occupancyStatus', `${occupancyStatus}`)}
|
|
236
|
+
value={t('occupancyStatus', `${occupancyStatus}`)}
|
|
264
237
|
key={`occupancyStatus-${index}`}
|
|
265
238
|
/>
|
|
266
239
|
))}
|
|
@@ -276,20 +249,13 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
276
249
|
render={({ field }) => (
|
|
277
250
|
<Select
|
|
278
251
|
id="bedType"
|
|
279
|
-
labelText={t(
|
|
280
|
-
invalidText={t(
|
|
252
|
+
labelText={t('bedType', 'Bed type')}
|
|
253
|
+
invalidText={t('required', 'Required')}
|
|
281
254
|
defaultValue={selectedBedType}
|
|
282
|
-
{...field}
|
|
283
|
-
|
|
284
|
-
<SelectItem
|
|
285
|
-
text={t("chooseBedtype", "Choose a bed type")}
|
|
286
|
-
/>
|
|
255
|
+
{...field}>
|
|
256
|
+
<SelectItem text={t('chooseBedtype', 'Choose a bed type')} />
|
|
287
257
|
{availableBedTypes.map((bedType, index) => (
|
|
288
|
-
<SelectItem
|
|
289
|
-
text={bedType.name}
|
|
290
|
-
value={bedType.name}
|
|
291
|
-
key={`bedType-${index}`}
|
|
292
|
-
>
|
|
258
|
+
<SelectItem text={bedType.name} value={bedType.name} key={`bedType-${index}`}>
|
|
293
259
|
{bedType.name}
|
|
294
260
|
</SelectItem>
|
|
295
261
|
))}
|
|
@@ -300,25 +266,25 @@ const BedAdministrationForm: React.FC<BedAdministrationFormProps> = ({
|
|
|
300
266
|
{showErrorNotification && (
|
|
301
267
|
<InlineNotification
|
|
302
268
|
lowContrast
|
|
303
|
-
title={t(
|
|
304
|
-
style={{ minWidth:
|
|
269
|
+
title={t('error', 'Error')}
|
|
270
|
+
style={{ minWidth: '100%', margin: '0', padding: '0' }}
|
|
305
271
|
role="alert"
|
|
306
272
|
kind="error"
|
|
307
|
-
subtitle={t(
|
|
273
|
+
subtitle={t('pleaseFillField', formStateError) + '.'}
|
|
308
274
|
onClose={() => setShowErrorNotification(false)}
|
|
309
275
|
/>
|
|
310
276
|
)}
|
|
311
277
|
</Stack>
|
|
312
|
-
</
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
</
|
|
320
|
-
</
|
|
321
|
-
</
|
|
278
|
+
</Form>
|
|
279
|
+
</ModalBody>
|
|
280
|
+
<ModalFooter>
|
|
281
|
+
<Button onClick={() => onModalChange(false)} kind="secondary">
|
|
282
|
+
{getCoreTranslation('cancel', 'Cancel')}
|
|
283
|
+
</Button>
|
|
284
|
+
<Button disabled={!isDirty} onClick={handleSubmit(onSubmit, onError)}>
|
|
285
|
+
<span>{t('save', 'Save')}</span>
|
|
286
|
+
</Button>
|
|
287
|
+
</ModalFooter>
|
|
322
288
|
</ComposedModal>
|
|
323
289
|
);
|
|
324
290
|
};
|