-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #929 from IFRCGo/project/healthcare-local-units
Health care data integration
- Loading branch information
Showing
30 changed files
with
1,243 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"go-web-app": minor | ||
--- | ||
|
||
Add table view in NS local units |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...rc/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/Filters/i18n.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"namespace": "nsLocalUnitsFilters", | ||
"strings": { | ||
"validated": "Validated", | ||
"notValidated": "Not Validated", | ||
"localUnitsFilterTypePlaceholder": "Type (All)", | ||
"localUnitsFilterTypeLabel": "Type", | ||
"localUnitsFilterClear": "Clear filters", | ||
"localUnitsFilterValidatedPlaceholder": "Validation (All)", | ||
"localUnitsFilterValidatedLabel": "Validation", | ||
"localUnitsFilterSearchLabel": "Search", | ||
"localUnitsFilterSearchPlaceholderLabel": "Search Local Units" | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
...rc/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/Filters/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { useMemo } from 'react'; | ||
import { SearchLineIcon } from '@ifrc-go/icons'; | ||
import { | ||
Button, | ||
SelectInput, | ||
TextInput, | ||
} from '@ifrc-go/ui'; | ||
import { useTranslation } from '@ifrc-go/ui/hooks'; | ||
import { | ||
stringLabelSelector, | ||
stringNameSelector, | ||
} from '@ifrc-go/ui/utils'; | ||
import { EntriesAsList } from '@togglecorp/toggle-form'; | ||
|
||
import { GoApiResponse } from '#utils/restRequest'; | ||
|
||
import { | ||
NOT_VALIDATED, | ||
VALIDATED, | ||
Validation, | ||
} from '../common'; | ||
|
||
import i18n from './i18n.json'; | ||
import styles from './styles.module.css'; | ||
|
||
interface ValidationOption { | ||
key: Validation | ||
label: string; | ||
} | ||
|
||
export interface FilterValue { | ||
search?: string | undefined; | ||
type?: number | undefined; | ||
isValidated?: Validation | undefined; | ||
} | ||
|
||
type LocalUnitOptions = GoApiResponse<'/api/v2/local-units-options/'>; | ||
type LocalUnitType = LocalUnitOptions['type'][number]; | ||
|
||
function localUnitCodeSelector(localUnit: LocalUnitType) { | ||
return localUnit.code; | ||
} | ||
|
||
function validationKeySelector(option: ValidationOption) { | ||
return option.key; | ||
} | ||
|
||
interface Props { | ||
value: FilterValue; | ||
setFieldValue: (...entries: EntriesAsList<FilterValue>) => void; | ||
options: LocalUnitOptions | undefined; | ||
resetFilter: () => void; | ||
filtered: boolean; | ||
} | ||
|
||
function Filters(props: Props) { | ||
const { | ||
value, | ||
setFieldValue: onChange, | ||
options, | ||
resetFilter, | ||
filtered, | ||
} = props; | ||
const strings = useTranslation(i18n); | ||
|
||
const validationOptions = useMemo((): ValidationOption[] => ([ | ||
{ | ||
key: VALIDATED, | ||
label: strings.validated, | ||
}, | ||
{ | ||
key: NOT_VALIDATED, | ||
label: strings.notValidated, | ||
}, | ||
]), [strings.validated, strings.notValidated]); | ||
|
||
return ( | ||
<> | ||
<SelectInput | ||
placeholder={strings.localUnitsFilterTypePlaceholder} | ||
label={strings.localUnitsFilterTypeLabel} | ||
name="type" | ||
value={value.type} | ||
onChange={onChange} | ||
keySelector={localUnitCodeSelector} | ||
labelSelector={stringNameSelector} | ||
options={options?.type} | ||
/> | ||
<SelectInput | ||
placeholder={strings.localUnitsFilterValidatedPlaceholder} | ||
label={strings.localUnitsFilterValidatedLabel} | ||
name="isValidated" | ||
value={value.isValidated} | ||
onChange={onChange} | ||
keySelector={validationKeySelector} | ||
labelSelector={stringLabelSelector} | ||
options={validationOptions} | ||
/> | ||
<TextInput | ||
name="search" | ||
label={strings.localUnitsFilterSearchLabel} | ||
placeholder={strings.localUnitsFilterSearchPlaceholderLabel} | ||
value={value.search} | ||
onChange={onChange} | ||
icons={<SearchLineIcon />} | ||
/> | ||
<div className={styles.actions}> | ||
<Button | ||
name={undefined} | ||
variant="secondary" | ||
onClick={resetFilter} | ||
disabled={!filtered} | ||
> | ||
{strings.localUnitsFilterClear} | ||
</Button> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default Filters; |
4 changes: 4 additions & 0 deletions
4
.../CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/Filters/styles.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.actions { | ||
display: flex; | ||
align-items: flex-end; | ||
} |
15 changes: 15 additions & 0 deletions
15
...ws/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/i18n.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"namespace": "nationalSocietyLocalUnits", | ||
"strings": { | ||
"localUnitDetailAddress": "Address", | ||
"localUnitDetailPhoneNumber": "Phone Number", | ||
"localUnitDetailLastUpdate": "Last Updated", | ||
"localUnitDetailFocalPerson": "Focal Person", | ||
"localUnitTooltipMoreDetails": "More Details", | ||
"localUnitLegendLocalUnitTitle": "Local Units", | ||
"localUnitLocalUnitType": "Local Unit Type", | ||
"localUnitHealthFacilityType": "Health Facility Type", | ||
"localUnitLegendHealthCareTitle": "Health Care Local Units", | ||
"localUnitDetailEmail": "Email" | ||
} | ||
} |
Oops, something went wrong.