-
Notifications
You must be signed in to change notification settings - Fork 0
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 #3 from openimis/feature/CM-453
CM-453: Create the UI component for field selection for deduplication.
- Loading branch information
Showing
4 changed files
with
84 additions
and
3 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
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,49 @@ | ||
import React, { useState } from 'react'; | ||
import { useTranslations, Autocomplete } from '@openimis/fe-core'; | ||
import { BASIC_FIELDS } from '../../constants'; | ||
|
||
function DeduplicationFieldPicker({ | ||
readOnly, | ||
benefitPlan, | ||
value, | ||
onChange, | ||
required, | ||
multiple = true, | ||
placeholder, | ||
withLabel, | ||
withPlaceholder, | ||
label, | ||
filterOptions, | ||
filterSelectedOptions, | ||
}) { | ||
const [searchString, setSearchString] = useState(); | ||
const { formatMessage } = useTranslations('deduplication'); | ||
|
||
const beneficiaryDataSchema = JSON.parse(benefitPlan?.beneficiaryDataSchema); | ||
const schemaFields = Object.keys(beneficiaryDataSchema?.properties ?? {}); | ||
const schemaFieldsList = schemaFields.map((key) => ({ id: key, name: key })); | ||
const possibleFields = [...schemaFieldsList, ...BASIC_FIELDS]; | ||
|
||
return ( | ||
<Autocomplete | ||
multiple={multiple} | ||
required={required} | ||
placeholder={placeholder ?? formatMessage('deduplication.deduplicate.fields.placeholder')} | ||
label={label ?? formatMessage('deduplication.deduplicate.fields')} | ||
error={[]} | ||
withLabel={withLabel} | ||
withPlaceholder={withPlaceholder} | ||
readOnly={readOnly} | ||
options={possibleFields} | ||
isLoading={false} | ||
value={value} | ||
getOptionLabel={(o) => o?.name} | ||
onChange={(option) => onChange(option, option?.name)} | ||
filterOptions={filterOptions} | ||
filterSelectedOptions={filterSelectedOptions} | ||
onInputChange={() => setSearchString(searchString)} | ||
/> | ||
); | ||
} | ||
|
||
export default DeduplicationFieldPicker; |
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,6 @@ | ||
export const BASIC_FIELDS = [ | ||
{ id: 'first_name', name: 'first_name' }, | ||
{ id: 'last_name', name: 'last_name' }, | ||
{ id: 'dob', name: 'dob' }, | ||
]; | ||
export const MODULE_NAME = 'Deduplication'; |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"deduplication.deduplicate": "Deduplicate", | ||
"deduplication.deduplicate.title": "Deduplication - {benefitPlanName}", | ||
"deduplication.deduplicate.button.cancel": "Cancel" | ||
"deduplication.deduplicate.button.cancel": "Cancel", | ||
"deduplication.deduplicate.fields": "Duplicate Detection Field Selection", | ||
"deduplication.deduplicate.fields.placeholder": "Duplicate Detection Field Selection", | ||
"deduplicate.button.showDuplicateSummary": "Show Duplicate Summary" | ||
} |