Skip to content

Commit cd19773

Browse files
authored
Merge pull request #929 from IFRCGo/project/healthcare-local-units
Health care data integration
2 parents ef63617 + 86cdd95 commit cd19773

File tree

30 files changed

+1243
-525
lines changed

30 files changed

+1243
-525
lines changed

.changeset/chilly-mails-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"go-web-app": minor
3+
---
4+
5+
Add table view in NS local units

app/src/hooks/useFilterState.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ function useFilterState<FILTER extends object>(options: {
134134
[],
135135
);
136136

137+
const resetFilter = useCallback(
138+
() => {
139+
dispatch({ type: 'reset-filter' });
140+
},
141+
[],
142+
);
143+
137144
const setFilterField = useCallback(
138145
(...args: EntriesAsList<FILTER>) => {
139146
const [val, key] = args;
@@ -190,6 +197,8 @@ function useFilterState<FILTER extends object>(options: {
190197
setFilter,
191198
setFilterField,
192199

200+
resetFilter,
201+
193202
page: state.page,
194203
offset: pageSize * (debouncedState.page - 1),
195204
limit: pageSize,

app/src/views/AccountDetails/GenerateMontandonTokenModal/i18n.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"strings": {
44
"title": "Generate token for Montandon",
55
"description": "By clicking 'Accept & Generate' button, you'll accept the {termsLink} of the Montandon API. Please make sure to review it.",
6-
"termsAndConditionLabel": "Terms & Condition",
6+
"termsAndConditionLabel": "Terms & Conditions",
77
"cancelButtonLabel": "Cancel",
88
"acceptButtonLabel": "Accept & Generate",
99
"doneButtonLabel": "Done",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"namespace": "nsLocalUnitsFilters",
3+
"strings": {
4+
"validated": "Validated",
5+
"notValidated": "Not Validated",
6+
"localUnitsFilterTypePlaceholder": "Type (All)",
7+
"localUnitsFilterTypeLabel": "Type",
8+
"localUnitsFilterClear": "Clear filters",
9+
"localUnitsFilterValidatedPlaceholder": "Validation (All)",
10+
"localUnitsFilterValidatedLabel": "Validation",
11+
"localUnitsFilterSearchLabel": "Search",
12+
"localUnitsFilterSearchPlaceholderLabel": "Search Local Units"
13+
}
14+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import { useMemo } from 'react';
2+
import { SearchLineIcon } from '@ifrc-go/icons';
3+
import {
4+
Button,
5+
SelectInput,
6+
TextInput,
7+
} from '@ifrc-go/ui';
8+
import { useTranslation } from '@ifrc-go/ui/hooks';
9+
import {
10+
stringLabelSelector,
11+
stringNameSelector,
12+
} from '@ifrc-go/ui/utils';
13+
import { EntriesAsList } from '@togglecorp/toggle-form';
14+
15+
import { GoApiResponse } from '#utils/restRequest';
16+
17+
import {
18+
NOT_VALIDATED,
19+
VALIDATED,
20+
Validation,
21+
} from '../common';
22+
23+
import i18n from './i18n.json';
24+
import styles from './styles.module.css';
25+
26+
interface ValidationOption {
27+
key: Validation
28+
label: string;
29+
}
30+
31+
export interface FilterValue {
32+
search?: string | undefined;
33+
type?: number | undefined;
34+
isValidated?: Validation | undefined;
35+
}
36+
37+
type LocalUnitOptions = GoApiResponse<'/api/v2/local-units-options/'>;
38+
type LocalUnitType = LocalUnitOptions['type'][number];
39+
40+
function localUnitCodeSelector(localUnit: LocalUnitType) {
41+
return localUnit.code;
42+
}
43+
44+
function validationKeySelector(option: ValidationOption) {
45+
return option.key;
46+
}
47+
48+
interface Props {
49+
value: FilterValue;
50+
setFieldValue: (...entries: EntriesAsList<FilterValue>) => void;
51+
options: LocalUnitOptions | undefined;
52+
resetFilter: () => void;
53+
filtered: boolean;
54+
}
55+
56+
function Filters(props: Props) {
57+
const {
58+
value,
59+
setFieldValue: onChange,
60+
options,
61+
resetFilter,
62+
filtered,
63+
} = props;
64+
const strings = useTranslation(i18n);
65+
66+
const validationOptions = useMemo((): ValidationOption[] => ([
67+
{
68+
key: VALIDATED,
69+
label: strings.validated,
70+
},
71+
{
72+
key: NOT_VALIDATED,
73+
label: strings.notValidated,
74+
},
75+
]), [strings.validated, strings.notValidated]);
76+
77+
return (
78+
<>
79+
<SelectInput
80+
placeholder={strings.localUnitsFilterTypePlaceholder}
81+
label={strings.localUnitsFilterTypeLabel}
82+
name="type"
83+
value={value.type}
84+
onChange={onChange}
85+
keySelector={localUnitCodeSelector}
86+
labelSelector={stringNameSelector}
87+
options={options?.type}
88+
/>
89+
<SelectInput
90+
placeholder={strings.localUnitsFilterValidatedPlaceholder}
91+
label={strings.localUnitsFilterValidatedLabel}
92+
name="isValidated"
93+
value={value.isValidated}
94+
onChange={onChange}
95+
keySelector={validationKeySelector}
96+
labelSelector={stringLabelSelector}
97+
options={validationOptions}
98+
/>
99+
<TextInput
100+
name="search"
101+
label={strings.localUnitsFilterSearchLabel}
102+
placeholder={strings.localUnitsFilterSearchPlaceholderLabel}
103+
value={value.search}
104+
onChange={onChange}
105+
icons={<SearchLineIcon />}
106+
/>
107+
<div className={styles.actions}>
108+
<Button
109+
name={undefined}
110+
variant="secondary"
111+
onClick={resetFilter}
112+
disabled={!filtered}
113+
>
114+
{strings.localUnitsFilterClear}
115+
</Button>
116+
</div>
117+
</>
118+
);
119+
}
120+
121+
export default Filters;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.actions {
2+
display: flex;
3+
align-items: flex-end;
4+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"namespace": "nationalSocietyLocalUnits",
3+
"strings": {
4+
"localUnitDetailAddress": "Address",
5+
"localUnitDetailPhoneNumber": "Phone Number",
6+
"localUnitDetailLastUpdate": "Last Updated",
7+
"localUnitDetailFocalPerson": "Focal Person",
8+
"localUnitTooltipMoreDetails": "More Details",
9+
"localUnitLegendLocalUnitTitle": "Local Units",
10+
"localUnitLocalUnitType": "Local Unit Type",
11+
"localUnitHealthFacilityType": "Health Facility Type",
12+
"localUnitLegendHealthCareTitle": "Health Care Local Units",
13+
"localUnitDetailEmail": "Email"
14+
}
15+
}

0 commit comments

Comments
 (0)