-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ismay
committed
Mar 14, 2024
1 parent
7456d18
commit d0853c0
Showing
4 changed files
with
66 additions
and
0 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,47 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import i18n from '@dhis2/d2-i18n' | ||
import { | ||
SingleSelectField, | ||
ReactFinalForm, | ||
SingleSelectFieldFF, | ||
} from '@dhis2/ui' | ||
import { testPolicies } from '../../../services/server-translations' | ||
|
||
const { Field } = ReactFinalForm | ||
|
||
const TestPolicyField = ({ label, name, constants }) => { | ||
if (constants.length === 0) { | ||
return ( | ||
<SingleSelectField | ||
label={label} | ||
helpText={i18n.t('No options available')} | ||
disabled | ||
/> | ||
) | ||
} | ||
|
||
const options = constants.map((option) => ({ | ||
value: option, | ||
label: testPolicies[option] || option, | ||
})) | ||
|
||
return ( | ||
<Field | ||
name={name} | ||
component={SingleSelectFieldFF} | ||
options={options} | ||
label={label} | ||
/> | ||
) | ||
} | ||
|
||
const { string, arrayOf } = PropTypes | ||
|
||
TestPolicyField.propTypes = { | ||
constants: arrayOf(string).isRequired, | ||
label: string.isRequired, | ||
name: string.isRequired, | ||
} | ||
|
||
export default TestPolicyField |
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
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,11 @@ | ||
import i18n from '@dhis2/d2-i18n' | ||
|
||
const testPolicies = { | ||
PARENT: i18n.t('Parent'), | ||
FAIL: i18n.t('Fail'), | ||
SKIP_STAGE: i18n.t('Skip stage'), | ||
SKIP_ITEM: i18n.t('Skip item'), | ||
SKIP_ITEM_OUTLIER: i18n.t('Skip item outlier'), | ||
} | ||
|
||
export default testPolicies |