@digihmis/esm-administration-app 1.0.0
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/README.md +4 -0
- package/dist/101.js +1 -0
- package/dist/101.js.map +1 -0
- package/dist/117.js +1 -0
- package/dist/117.js.map +1 -0
- package/dist/132.js +1 -0
- package/dist/132.js.map +1 -0
- package/dist/15.js +1 -0
- package/dist/15.js.map +1 -0
- package/dist/152.js +1 -0
- package/dist/152.js.map +1 -0
- package/dist/153.js +1 -0
- package/dist/153.js.map +1 -0
- package/dist/190.js +1 -0
- package/dist/190.js.map +1 -0
- package/dist/209.js +1 -0
- package/dist/209.js.map +1 -0
- package/dist/266.js +1 -0
- package/dist/266.js.map +1 -0
- package/dist/317.js +1 -0
- package/dist/317.js.map +1 -0
- package/dist/349.js +1 -0
- package/dist/349.js.map +1 -0
- package/dist/371.js +1 -0
- package/dist/371.js.map +1 -0
- package/dist/378.js +1 -0
- package/dist/378.js.map +1 -0
- package/dist/394.js +1 -0
- package/dist/394.js.map +1 -0
- package/dist/442.js +1 -0
- package/dist/442.js.map +1 -0
- package/dist/45.js +1 -0
- package/dist/45.js.map +1 -0
- package/dist/454.js +1 -0
- package/dist/454.js.map +1 -0
- package/dist/466.js +1 -0
- package/dist/466.js.map +1 -0
- package/dist/482.js +1 -0
- package/dist/482.js.map +1 -0
- package/dist/501.js +1 -0
- package/dist/501.js.map +1 -0
- package/dist/508.js +1 -0
- package/dist/508.js.map +1 -0
- package/dist/578.js +1 -0
- package/dist/578.js.map +1 -0
- package/dist/598.js +1 -0
- package/dist/598.js.map +1 -0
- package/dist/606.js +1 -0
- package/dist/606.js.map +1 -0
- package/dist/61.js +1 -0
- package/dist/61.js.map +1 -0
- package/dist/640.js +1 -0
- package/dist/640.js.map +1 -0
- package/dist/685.js +1 -0
- package/dist/685.js.map +1 -0
- package/dist/689.js +1 -0
- package/dist/689.js.map +1 -0
- package/dist/709.js +1 -0
- package/dist/709.js.map +1 -0
- package/dist/712.js +1 -0
- package/dist/712.js.map +1 -0
- package/dist/720.js +1 -0
- package/dist/720.js.map +1 -0
- package/dist/737.js +12 -0
- package/dist/737.js.map +1 -0
- package/dist/742.js +1 -0
- package/dist/742.js.map +1 -0
- package/dist/747.js +1 -0
- package/dist/747.js.map +1 -0
- package/dist/771.js +1 -0
- package/dist/771.js.map +1 -0
- package/dist/806.js +1 -0
- package/dist/806.js.map +1 -0
- package/dist/912.js +1 -0
- package/dist/912.js.map +1 -0
- package/dist/913.js +1 -0
- package/dist/913.js.map +1 -0
- package/dist/916.js +15 -0
- package/dist/916.js.map +1 -0
- package/dist/940.js +1 -0
- package/dist/940.js.map +1 -0
- package/dist/digihmis-esm-administration-app.js +6 -0
- package/dist/digihmis-esm-administration-app.js.buildmanifest.json +1100 -0
- package/dist/digihmis-esm-administration-app.js.map +1 -0
- package/dist/main.js +17 -0
- package/dist/main.js.map +1 -0
- package/dist/routes.json +1 -0
- package/increment-version.js +17 -0
- package/jest.config.js +26 -0
- package/package.json +51 -0
- package/release-version.js +16 -0
- package/rspack.config.js +1 -0
- package/src/bed-management/bed-management.component.tsx +19 -0
- package/src/bed-management/bed-management.scss +0 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-modal/billing-charge-items.modal.tsx +79 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-modal/billing-charge-items.resource.ts +11 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/billing-charge-item.workspace.tsx +212 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/billing-charge-items.resource.ts +51 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/billing-charge-service.workspace.tsx +296 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/components/concept-search.component.tsx +67 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/components/price.component.tsx +81 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/components/stock-search.component.tsx +107 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/global/billing-charge-commodity.scss +61 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/global/billing-charge-items.scss +59 -0
- package/src/billing-management/billing-charge-items/billing-charge-items-workspace/schemas/form-schemas.ts +33 -0
- package/src/billing-management/billing-charge-items/billing-charge-items.component.tsx +222 -0
- package/src/billing-management/billing-charge-items/billing-charge-items.resource.ts +20 -0
- package/src/billing-management/billing-charge-items/billing-charge-items.scss +84 -0
- package/src/billing-management/billing-charge-items/type/index.ts +88 -0
- package/src/billing-management/billing-charge-items/utils/index.ts +96 -0
- package/src/billing-management/billing-management.component.tsx +21 -0
- package/src/billing-management/billing-management.scss +0 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-modal/billing-delete-payment-modes.modal.scss +28 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-modal/billing-delete-payment-modes.modal.tsx +67 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-modal/delete-payment-mode.test.tsx +56 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-workspace/billing-payment-modes-form-schema.ts +52 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-workspace/billing-payment-modes.resource.ts +35 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-workspace/billing-payment-modes.workspace.scss +33 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-workspace/billing-payment-modes.workspace.test.tsx +239 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-workspace/billing-payment-modes.workspace.tsx +218 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-workspace/payment-attributes/payment-mode-attributes.component.tsx +156 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes-workspace/payment-attributes/payment-mode-attributes.scss +10 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes.component.tsx +243 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes.resource.ts +23 -0
- package/src/billing-management/billing-payment-modes/billing-payment-modes.scss +140 -0
- package/src/billing-management/billing-payment-modes/type/index.ts +42 -0
- package/src/billing-management/billing-payment-points/billing-payment-point-modal/billing-delete-payment-modes.modal.scss +28 -0
- package/src/billing-management/billing-payment-points/billing-payment-point-modal/billing-delete-payment-point.modal.tsx +72 -0
- package/src/billing-management/billing-payment-points/billing-payment-point-modal/delete-payment-point.test.tsx +56 -0
- package/src/billing-management/billing-payment-points/billing-payment-point.component.tsx +202 -0
- package/src/billing-management/billing-payment-points/billing-payment-point.resource.ts +16 -0
- package/src/billing-management/billing-payment-points/billing-payment-point.scss +0 -0
- package/src/billing-management/billing-payment-points/billing-payment-points-workspace/billing-payment-point.resource.ts +39 -0
- package/src/billing-management/billing-payment-points/billing-payment-points-workspace/billing-payment-point.workspace.scss +33 -0
- package/src/billing-management/billing-payment-points/billing-payment-points-workspace/billing-payment-points.workspace.tsx +194 -0
- package/src/billing-management/billing-payment-points/type/index.ts +35 -0
- package/src/billing-management/billing-tabs/billing-tabs.component.scss +15 -0
- package/src/billing-management/billing-tabs/billing-tabs.component.tsx +36 -0
- package/src/components/custom-icon-wrapper/custom-icon-wrapper.component.tsx +17 -0
- package/src/components/custom-page-header/custom-page-header.component.tsx +38 -0
- package/src/components/custom-page-header/custom-page-header.scss +76 -0
- package/src/config-schema.ts +142 -0
- package/src/constant/index.ts +1 -0
- package/src/dashboard.meta.ts +47 -0
- package/src/declarations.d.ts +6 -0
- package/src/form-builder/form-builder.component.tsx +19 -0
- package/src/form-builder/form-builder.scss +0 -0
- package/src/hooks/useConcept.ts +13 -0
- package/src/hooks/useQueues.ts +22 -0
- package/src/hooks/useSystemSetting.ts +18 -0
- package/src/index.ts +133 -0
- package/src/left-panel/left-panel.component.tsx +49 -0
- package/src/left-panel/left-panel.scss +13 -0
- package/src/location-management/components/auto-suggest/autosuggest.component.tsx +149 -0
- package/src/location-management/components/auto-suggest/autosuggest.scss +61 -0
- package/src/location-management/components/auto-suggest/location-autosuggest.component.tsx +97 -0
- package/src/location-management/components/auto-suggest/location-autosuggest.scss +48 -0
- package/src/location-management/components/custom-results-tile/results-tile.component.tsx +43 -0
- package/src/location-management/components/custom-results-tile/results-tile.scss +86 -0
- package/src/location-management/forms/add-location/add-location.workspace.scss +71 -0
- package/src/location-management/forms/add-location/add-location.workspace.tsx +199 -0
- package/src/location-management/forms/search-location/search-location.workspace.scss +71 -0
- package/src/location-management/forms/search-location/search-location.workspace.tsx +214 -0
- package/src/location-management/helpers/index.ts +33 -0
- package/src/location-management/hooks/UseFacilityLocations.ts +12 -0
- package/src/location-management/hooks/useLocation.ts +18 -0
- package/src/location-management/hooks/useLocationTags.ts +15 -0
- package/src/location-management/location-management-dashboard.component.tsx +21 -0
- package/src/location-management/location-management-dashboard.scss +3 -0
- package/src/location-management/tables/locations-table.component.tsx +242 -0
- package/src/location-management/tables/locations-table.resource.ts +26 -0
- package/src/location-management/tables/locations-table.scss +114 -0
- package/src/location-management/types/index.ts +120 -0
- package/src/queue-management/queue-management-dashboard.component.tsx +23 -0
- package/src/queue-management/queue-management-dashboard.scss +8 -0
- package/src/queue-management/queue-management-table/queue-management-table.component.tsx +296 -0
- package/src/queue-management/queue-management-table/queue-management-table.scss +78 -0
- package/src/queue-management/queue-management-table/queue-management.resource.ts +39 -0
- package/src/queue-management/queue-management-workspace/queue-room/queue-room-form.scss +56 -0
- package/src/queue-management/queue-management-workspace/queue-room/queue-room-form.test.tsx +82 -0
- package/src/queue-management/queue-management-workspace/queue-room/queue-room-form.workspace.tsx +169 -0
- package/src/queue-management/queue-management-workspace/queue-room/queue-room.resource.ts +20 -0
- package/src/queue-management/queue-management-workspace/queue-service/queue-service-form.scss +61 -0
- package/src/queue-management/queue-management-workspace/queue-service/queue-service-form.test.tsx +127 -0
- package/src/queue-management/queue-management-workspace/queue-service/queue-service-form.workspace.tsx +178 -0
- package/src/queue-management/queue-management-workspace/queue-service/queue-service.resource.ts +55 -0
- package/src/queue-management/queue-types/index.ts +33 -0
- package/src/routes.json +157 -0
- package/src/setup-tests.ts +1 -0
- package/src/system-info/system-info.component.tsx +338 -0
- package/src/system-info/system-info.resource.ts +40 -0
- package/src/system-info/system-info.scss +622 -0
- package/src/type/index.ts +6 -0
- package/translations/am.json +111 -0
- package/translations/ar.json +115 -0
- package/translations/en.json +111 -0
- package/translations/es.json +112 -0
- package/translations/fr.json +112 -0
- package/translations/he.json +112 -0
- package/translations/km.json +110 -0
- package/translations/pt.json +112 -0
- package/translations/sw.json +111 -0
- package/translations/vi.json +110 -0
- package/translations/zh.json +110 -0
- package/tsconfig.json +5 -0
- package/version.js +27 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { InlineLoading, Layer, Search } from '@carbon/react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import React, { type HTMLAttributes, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import styles from './autosuggest.scss';
|
|
6
|
+
|
|
7
|
+
type InputPropsBase = Omit<HTMLAttributes<HTMLInputElement>, 'onChange'>;
|
|
8
|
+
|
|
9
|
+
interface SearchProps extends InputPropsBase {
|
|
10
|
+
autoComplete?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
closeButtonLabelText?: string;
|
|
13
|
+
defaultValue?: string | number;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
isExpanded?: boolean;
|
|
16
|
+
id?: string;
|
|
17
|
+
labelText: React.ReactNode;
|
|
18
|
+
onChange?(e: { target: HTMLInputElement; type: 'change' }): void;
|
|
19
|
+
onClear?(): void;
|
|
20
|
+
onExpand?(e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>): void;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
renderIcon?: React.ComponentType | React.FunctionComponent;
|
|
23
|
+
role?: string;
|
|
24
|
+
size?: 'sm' | 'md' | 'lg';
|
|
25
|
+
type?: string;
|
|
26
|
+
value?: string | number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface AutosuggestProps extends SearchProps {
|
|
30
|
+
getDisplayValue: (item: any) => string;
|
|
31
|
+
getFieldValue: (item: any) => string;
|
|
32
|
+
getSearchResults: (query: string) => Promise<any>;
|
|
33
|
+
onSuggestionSelected: (field: string, value: string) => void;
|
|
34
|
+
invalid?: boolean;
|
|
35
|
+
invalidText?: string;
|
|
36
|
+
renderSuggestionItem?: (item: any) => React.ReactNode;
|
|
37
|
+
renderEmptyState?: (value: any) => React.ReactNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Autosuggest: React.FC<AutosuggestProps> = ({
|
|
41
|
+
getDisplayValue,
|
|
42
|
+
getFieldValue,
|
|
43
|
+
getSearchResults,
|
|
44
|
+
onSuggestionSelected,
|
|
45
|
+
invalid,
|
|
46
|
+
invalidText,
|
|
47
|
+
renderSuggestionItem,
|
|
48
|
+
renderEmptyState,
|
|
49
|
+
...searchProps
|
|
50
|
+
}) => {
|
|
51
|
+
const { t } = useTranslation();
|
|
52
|
+
const [suggestions, setSuggestions] = useState<any[]>([]);
|
|
53
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
54
|
+
const searchBox = useRef<HTMLInputElement>(null);
|
|
55
|
+
const wrapper = useRef<HTMLDivElement>(null);
|
|
56
|
+
const { id: name, labelText } = searchProps;
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const handleClickOutsideComponent = (e: MouseEvent) => {
|
|
60
|
+
if (wrapper.current && !wrapper.current.contains(e.target as Node)) {
|
|
61
|
+
setSuggestions([]);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
document.addEventListener('mousedown', handleClickOutsideComponent);
|
|
66
|
+
return () => {
|
|
67
|
+
document.removeEventListener('mousedown', handleClickOutsideComponent);
|
|
68
|
+
};
|
|
69
|
+
}, [wrapper]);
|
|
70
|
+
|
|
71
|
+
const handleChange = (e) => {
|
|
72
|
+
const query = e.target.value;
|
|
73
|
+
onSuggestionSelected(name, undefined);
|
|
74
|
+
|
|
75
|
+
if (query && query.trim()) {
|
|
76
|
+
setIsLoading(true);
|
|
77
|
+
getSearchResults(query.trim())
|
|
78
|
+
.then((results) => {
|
|
79
|
+
setSuggestions(results || []);
|
|
80
|
+
setIsLoading(false);
|
|
81
|
+
})
|
|
82
|
+
.catch((error) => {
|
|
83
|
+
setSuggestions([]);
|
|
84
|
+
setIsLoading(false);
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
setSuggestions([]);
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const handleClear = () => {
|
|
93
|
+
onSuggestionSelected(name, undefined);
|
|
94
|
+
setSuggestions([]);
|
|
95
|
+
setIsLoading(false);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const handleClick = (index: number) => {
|
|
99
|
+
const selectedSuggestion = suggestions[index];
|
|
100
|
+
if (selectedSuggestion) {
|
|
101
|
+
const fieldValue = getFieldValue(selectedSuggestion);
|
|
102
|
+
const displayValue = getDisplayValue(selectedSuggestion);
|
|
103
|
+
if (searchBox.current) {
|
|
104
|
+
searchBox.current.value = displayValue;
|
|
105
|
+
}
|
|
106
|
+
onSuggestionSelected(name, fieldValue);
|
|
107
|
+
setSuggestions([]);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div className={styles.autocomplete} ref={wrapper}>
|
|
113
|
+
<label className="cds--label">{labelText}</label>
|
|
114
|
+
<Layer className={classNames({ [styles.invalid]: invalid })}>
|
|
115
|
+
<Search
|
|
116
|
+
id="autosuggest"
|
|
117
|
+
onChange={handleChange}
|
|
118
|
+
onClear={handleClear}
|
|
119
|
+
ref={searchBox}
|
|
120
|
+
className={styles.autocompleteSearch}
|
|
121
|
+
{...searchProps}
|
|
122
|
+
/>
|
|
123
|
+
</Layer>
|
|
124
|
+
{isLoading && (
|
|
125
|
+
<div className={styles.loading}>
|
|
126
|
+
<InlineLoading status="active" description={t('loading', 'Loading...')} />
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
{suggestions.length > 0 ? (
|
|
130
|
+
<ul className={styles.suggestions}>
|
|
131
|
+
{suggestions.map((suggestion, index) => {
|
|
132
|
+
return (
|
|
133
|
+
<li
|
|
134
|
+
key={getFieldValue(suggestion) || index}
|
|
135
|
+
onClick={() => handleClick(index)}
|
|
136
|
+
role="presentation"
|
|
137
|
+
style={{ cursor: 'pointer' }}>
|
|
138
|
+
{renderSuggestionItem ? renderSuggestionItem(suggestion) : getDisplayValue(suggestion)}
|
|
139
|
+
</li>
|
|
140
|
+
);
|
|
141
|
+
})}
|
|
142
|
+
</ul>
|
|
143
|
+
) : (
|
|
144
|
+
!isLoading && renderEmptyState && renderEmptyState(searchBox.current?.value || '')
|
|
145
|
+
)}
|
|
146
|
+
{invalid && <label className={classNames(styles.invalidMsg)}>{invalidText}</label>}
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@use '@carbon/layout';
|
|
2
|
+
@use '@carbon/type';
|
|
3
|
+
@use '@carbon/colors';
|
|
4
|
+
|
|
5
|
+
.label01 {
|
|
6
|
+
@include type.type-style('label-01');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.suggestions {
|
|
10
|
+
position: relative;
|
|
11
|
+
border-top-width: 0;
|
|
12
|
+
list-style: none;
|
|
13
|
+
margin-top: 0;
|
|
14
|
+
max-height: 400px;
|
|
15
|
+
overflow-y: auto;
|
|
16
|
+
padding-left: 0;
|
|
17
|
+
width: 100%;
|
|
18
|
+
position: absolute;
|
|
19
|
+
left: 0;
|
|
20
|
+
background-color: colors.$white;
|
|
21
|
+
margin-bottom: 20px;
|
|
22
|
+
z-index: 99;
|
|
23
|
+
box-shadow: layout.$spacing-03 layout.$spacing-03 layout.$spacing-03 layout.$spacing-03 colors.$gray-30;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.suggestions li {
|
|
27
|
+
color: colors.$gray-70;
|
|
28
|
+
border-bottom: 1px solid colors.$gray-50;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.displayText {
|
|
32
|
+
padding: layout.$spacing-05;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.suggestions li:not(:last-of-type) {
|
|
36
|
+
border-bottom: 1px solid colors.$gray-40-hover;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.autocomplete {
|
|
40
|
+
position: relative;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.autocompleteSearch {
|
|
44
|
+
width: 100%;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.suggestions a {
|
|
48
|
+
color: inherit;
|
|
49
|
+
text-decoration: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.invalid input {
|
|
53
|
+
outline: 2px solid var(--cds-support-error, colors.$red-60);
|
|
54
|
+
outline-offset: -2px;
|
|
55
|
+
margin-bottom: layout.$spacing-02;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.invalidMsg {
|
|
59
|
+
color: var(--cds-text-error, colors.$red-60);
|
|
60
|
+
font-size: small;
|
|
61
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Tile } from '@carbon/react';
|
|
2
|
+
import React, { useCallback, useState } from 'react';
|
|
3
|
+
import { Autosuggest } from './autosuggest.component';
|
|
4
|
+
import styles from './location-autosuggest.scss';
|
|
5
|
+
import { type LocationResponse } from '../../types';
|
|
6
|
+
import ResultsTile from '../custom-results-tile/results-tile.component';
|
|
7
|
+
import { searchLocation } from '../../hooks/UseFacilityLocations';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
|
|
10
|
+
interface LocationAutosuggestProps {
|
|
11
|
+
onLocationSelected: (locationUuid: string, locationData: LocationResponse) => void;
|
|
12
|
+
labelText?: string;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
invalid?: boolean;
|
|
15
|
+
invalidText?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const LocationAutosuggest: React.FC<LocationAutosuggestProps> = ({
|
|
19
|
+
onLocationSelected,
|
|
20
|
+
labelText = 'Select Location',
|
|
21
|
+
placeholder = 'Search for a location...',
|
|
22
|
+
invalid = false,
|
|
23
|
+
invalidText = 'Please select a valid location',
|
|
24
|
+
}) => {
|
|
25
|
+
const [searchResults, setSearchResults] = useState<LocationResponse[]>([]);
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
|
|
28
|
+
const getDisplayValue = useCallback((item: LocationResponse) => {
|
|
29
|
+
return item.display || item.name || '';
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
const getFieldValue = useCallback((item: LocationResponse) => {
|
|
33
|
+
return item.uuid || '';
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
const handleSuggestionSelected = useCallback(
|
|
37
|
+
(field: string, value: string) => {
|
|
38
|
+
if (value) {
|
|
39
|
+
const selected = searchResults.find((item) => item.uuid === value);
|
|
40
|
+
if (selected) {
|
|
41
|
+
onLocationSelected(value, selected);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
[onLocationSelected, searchResults],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const handleSearchResults = useCallback(async (query: string) => {
|
|
49
|
+
const results = await searchLocation(query);
|
|
50
|
+
setSearchResults(results);
|
|
51
|
+
return results;
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
const renderSuggestionItem = useCallback((item: LocationResponse) => {
|
|
55
|
+
return (
|
|
56
|
+
<div>
|
|
57
|
+
<ResultsTile location={item} />
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
const renderEmptyState = useCallback(
|
|
63
|
+
(value: string) => {
|
|
64
|
+
if (!value) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className={styles.tileContainer}>
|
|
70
|
+
<Tile className={styles.tileNoContent}>
|
|
71
|
+
<div className={styles.tileContents}>
|
|
72
|
+
<p className={styles.content}>{t('searchNoResults', `Found no matching results`)}</p>
|
|
73
|
+
<p className={styles.helper}>{t('searchNoResultsHelper', 'Try searching for a different term')}</p>
|
|
74
|
+
</div>
|
|
75
|
+
</Tile>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
[t],
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Autosuggest
|
|
84
|
+
id="location-autosuggest"
|
|
85
|
+
labelText={labelText}
|
|
86
|
+
placeholder={placeholder}
|
|
87
|
+
getDisplayValue={getDisplayValue}
|
|
88
|
+
getFieldValue={getFieldValue}
|
|
89
|
+
getSearchResults={handleSearchResults}
|
|
90
|
+
onSuggestionSelected={handleSuggestionSelected}
|
|
91
|
+
renderSuggestionItem={renderSuggestionItem}
|
|
92
|
+
renderEmptyState={renderEmptyState}
|
|
93
|
+
invalid={invalid}
|
|
94
|
+
invalidText={invalidText}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
4
|
+
|
|
5
|
+
.tileContainer {
|
|
6
|
+
background-color: colors.$white-0;
|
|
7
|
+
border-top: 1px solid colors.$gray-20;
|
|
8
|
+
padding: layout.$spacing-09 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.tileNoContent {
|
|
12
|
+
margin: auto;
|
|
13
|
+
width: fit-content;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.tileContent {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: layout.$spacing-05;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.details {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
align-items: flex-start;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.content {
|
|
33
|
+
@include type.type-style('heading-compact-02');
|
|
34
|
+
color: colors.$gray-70;
|
|
35
|
+
margin-bottom: layout.$spacing-03;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.helper {
|
|
39
|
+
@include type.type-style('body-compact-01');
|
|
40
|
+
color: colors.$gray-70;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.illustrationPictogram {
|
|
44
|
+
width: layout.$spacing-07;
|
|
45
|
+
height: layout.$spacing-07;
|
|
46
|
+
fill: var(--brand-03);
|
|
47
|
+
flex-shrink: 0;
|
|
48
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Tag, Tile } from '@carbon/react';
|
|
4
|
+
import { Hospital } from '@carbon/pictograms-react';
|
|
5
|
+
import styles from './results-tile.scss';
|
|
6
|
+
import { Close } from '@carbon/react/icons';
|
|
7
|
+
import { type LocationResponse } from '../../types';
|
|
8
|
+
|
|
9
|
+
interface ResultsTileProps {
|
|
10
|
+
location?: LocationResponse;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ResultsTile: React.FC<ResultsTileProps> = ({ location, onClose }) => {
|
|
15
|
+
return (
|
|
16
|
+
<Tile className={styles.tile}>
|
|
17
|
+
<div className={styles.tileContent}>
|
|
18
|
+
{onClose && <Close size={16} className={styles.closeIcon} onClick={onClose} />}
|
|
19
|
+
<Hospital className={styles.illustrationPictogram} />
|
|
20
|
+
<div className={styles.details}>
|
|
21
|
+
<div className={styles.locationName}>{location.display || location.name}</div>
|
|
22
|
+
{location.description && <div className={styles.description}>{location.description}</div>}
|
|
23
|
+
{(location.stateProvince || location.country) && (
|
|
24
|
+
<div className={styles.locationDetails}>
|
|
25
|
+
{[location.stateProvince, location.country].filter(Boolean).join(', ')}
|
|
26
|
+
</div>
|
|
27
|
+
)}
|
|
28
|
+
{location.tags && (
|
|
29
|
+
<div className={styles.tags}>
|
|
30
|
+
{location.tags.map((tag, index) => (
|
|
31
|
+
<Tag key={index} className={styles.tag}>
|
|
32
|
+
{tag.display || tag.name}
|
|
33
|
+
</Tag>
|
|
34
|
+
))}
|
|
35
|
+
</div>
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</Tile>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default ResultsTile;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
4
|
+
|
|
5
|
+
.tile {
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.tileContainer {
|
|
10
|
+
background-color: colors.$white-0;
|
|
11
|
+
border-top: 1px solid colors.$gray-20;
|
|
12
|
+
padding: layout.$spacing-10 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tileNoContent {
|
|
16
|
+
margin: auto;
|
|
17
|
+
width: fit-content;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
align-items: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tileContent {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: row;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: layout.$spacing-05;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.details {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.content {
|
|
37
|
+
@include type.type-style('heading-compact-02');
|
|
38
|
+
color: colors.$gray-70;
|
|
39
|
+
margin-bottom: layout.$spacing-03;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.helper {
|
|
43
|
+
@include type.type-style('body-compact-01');
|
|
44
|
+
color: colors.$gray-70;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.illustrationPictogram {
|
|
48
|
+
width: layout.$spacing-07;
|
|
49
|
+
height: layout.$spacing-07;
|
|
50
|
+
fill: var(--brand-03);
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.closeIcon {
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: layout.$spacing-03;
|
|
57
|
+
right: layout.$spacing-03;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
color: colors.$gray-70;
|
|
60
|
+
|
|
61
|
+
&:hover {
|
|
62
|
+
color: colors.$gray-100;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.description {
|
|
67
|
+
@include type.type-style('body-compact-01');
|
|
68
|
+
color: colors.$gray-70;
|
|
69
|
+
margin-bottom: layout.$spacing-03;
|
|
70
|
+
font-size: layout.$spacing-01;
|
|
71
|
+
}
|
|
72
|
+
.locationName {
|
|
73
|
+
@include type.type-style('body-compact-01');
|
|
74
|
+
color: colors.$gray-70;
|
|
75
|
+
font-weight: bold;
|
|
76
|
+
}
|
|
77
|
+
.locationDetails {
|
|
78
|
+
@include type.type-style('body-compact-01');
|
|
79
|
+
color: colors.$gray-70;
|
|
80
|
+
font-size: layout.$spacing-01;
|
|
81
|
+
}
|
|
82
|
+
.tags {
|
|
83
|
+
@include type.type-style('body-compact-01');
|
|
84
|
+
color: colors.$gray-70;
|
|
85
|
+
font-size: layout.$spacing-01;
|
|
86
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
4
|
+
|
|
5
|
+
.form {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
height: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.formContainer {
|
|
13
|
+
margin: layout.$spacing-05;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: layout.$spacing-05;
|
|
17
|
+
|
|
18
|
+
:global(.omrs-breakpoint-lt-tablet) & {
|
|
19
|
+
margin: layout.$spacing-03;
|
|
20
|
+
gap: layout.$spacing-03;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.tablet {
|
|
25
|
+
padding: layout.$spacing-06 layout.$spacing-05;
|
|
26
|
+
background-color: colors.$white;
|
|
27
|
+
|
|
28
|
+
:global(.omrs-breakpoint-lt-tablet) & {
|
|
29
|
+
padding: layout.$spacing-05 layout.$spacing-03;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.desktop {
|
|
34
|
+
padding: 0;
|
|
35
|
+
margin: 0 layout.$spacing-05 layout.$spacing-05;
|
|
36
|
+
|
|
37
|
+
:global(.omrs-breakpoint-lt-desktop) & {
|
|
38
|
+
margin: 0 layout.$spacing-03 layout.$spacing-03;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.buttonContainer {
|
|
43
|
+
height: layout.$spacing-10;
|
|
44
|
+
display: flex;
|
|
45
|
+
align-content: flex-start;
|
|
46
|
+
align-items: baseline;
|
|
47
|
+
min-width: 50%;
|
|
48
|
+
|
|
49
|
+
:global(.omrs-breakpoint-lt-tablet) & {
|
|
50
|
+
max-width: none;
|
|
51
|
+
flex: 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.inlineLoading {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
gap: layout.$spacing-03;
|
|
59
|
+
|
|
60
|
+
:global(.omrs-breakpoint-lt-tablet) & {
|
|
61
|
+
gap: layout.$spacing-02;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.button {
|
|
66
|
+
height: layout.$spacing-10;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-content: flex-start;
|
|
69
|
+
align-items: baseline;
|
|
70
|
+
min-width: 50%;
|
|
71
|
+
}
|