From 376e1a6ed0f79e43a39d7f1c41aa8c35fe6305a6 Mon Sep 17 00:00:00 2001 From: olewandowski1 Date: Wed, 14 Feb 2024 15:03:56 +0100 Subject: [PATCH] OM-122: make generic vouchers configurable --- README.md | 3 ++- src/components/VoucherAcquirementForm.js | 16 +++++++++++++--- src/constants.js | 4 ++++ src/index.js | 3 ++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d112dc5..72d684f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ In development mode, you can use `npm link` and `npm start` to continuously scan __Workers and Vouchers__ ('worker.MainMenu') - it is displayed if __"isWorker"__ variable is set to __true__. **Workers** ('menu.workers') - workers list, it is displayed if __"isWorker"__ variable is set to __true__. **Voucher List** ('menu.voucherList') - vouchers list, it is displayed if user has `204001` right - **Voucher Acquirement** ('menu.voucherAcquirement') - voucher acquirement form, it is displayed if user has `204001` right + **Voucher Acquirement** ('menu.voucherAcquirement') - voucher acquirement form, it is displayed if user has `204001` right **Voucher Assignment** ('menu.voucherAssignment') - voucher assignment form, it is displayed if user has `204001` right __Administration__ ('admin.mainMenu') - it is displayed by default, main entry of admin module @@ -53,3 +53,4 @@ __Administration__ ('admin.mainMenu') - it is displayed by default, main entry o ## Configurations Options - `isWorker`: Specifies whether the individual should be classified and managed as a worker or a standard insuree. In Moldova, the Insuree entity is also used to represent workers. When set to true, the system displays 'Workers and Vouchers' instead of the default 'Insurees and Policies', aligning the interface with the specific needs of worker representation. Default: __false__. +- `genericVoucherEnabled`: Specifies whether the system should enable the use of generic vouchers for the individual. When set to true, the system provides additional functionalities for handling generic vouchers, aligning the interface with the specific needs of voucher management. Default: __false__. diff --git a/src/components/VoucherAcquirementForm.js b/src/components/VoucherAcquirementForm.js index ddff15e..bce06a5 100644 --- a/src/components/VoucherAcquirementForm.js +++ b/src/components/VoucherAcquirementForm.js @@ -6,7 +6,7 @@ import { import { makeStyles } from '@material-ui/styles'; import { useModulesManager, useTranslations, PublishedComponent } from '@openimis/fe-core'; -import { ACQUIREMENT_METHOD, MODULE_NAME } from '../constants'; +import { ACQUIREMENT_METHOD, DEFAULT, MODULE_NAME } from '../constants'; import VoucherAcquirementGenericVoucher from './VoucherAcquirementGenericVoucher'; import VoucherAcquirementSpecificWorker from './VoucherAcquirementSpecificWorker'; @@ -21,7 +21,14 @@ function VoucherAcquirementForm() { const modulesManager = useModulesManager(); const classes = useStyles(); const { formatMessage } = useTranslations(MODULE_NAME, modulesManager); - const [acquirementMethod, setAcquirementMethod] = useState(null); + const genericVoucherEnabled = modulesManager.getConf( + 'fe-worker_voucher', + 'genericVoucherEnabled', + DEFAULT.GENERIC_VOUCHER_ENABLED, + ); + const [acquirementMethod, setAcquirementMethod] = useState( + genericVoucherEnabled ? null : ACQUIREMENT_METHOD.SPECIFIC_WORKER, + ); return ( <> @@ -36,9 +43,11 @@ function VoucherAcquirementForm() { + { genericVoucherEnabled && ( {formatMessage('workerVoucher.VoucherAcquirementForm.subtitle')} + )} @@ -48,6 +57,7 @@ function VoucherAcquirementForm() { nullLabel="workerVoucher.acquirement.method.NONE" acquirementMethod={acquirementMethod} setAcquirementMethod={setAcquirementMethod} + readOnly={!genericVoucherEnabled} required withNull withLabel @@ -61,7 +71,7 @@ function VoucherAcquirementForm() { - {acquirementMethod === ACQUIREMENT_METHOD.GENERIC_VOUCHER && ( + {genericVoucherEnabled && acquirementMethod === ACQUIREMENT_METHOD.GENERIC_VOUCHER && ( )} {acquirementMethod === ACQUIREMENT_METHOD.SPECIFIC_WORKER && ( diff --git a/src/constants.js b/src/constants.js index 95b8f7b..c1b20be 100644 --- a/src/constants.js +++ b/src/constants.js @@ -51,3 +51,7 @@ export const WORKER_VOUCHER_STATUS_LIST = [ WORKER_VOUCHER_STATUS.CANCELED, WORKER_VOUCHER_STATUS.CLOSED, ]; + +export const DEFAULT = { + GENERIC_VOUCHER_ENABLED: false, +}; diff --git a/src/index.js b/src/index.js index 12be80f..c25ad4a 100644 --- a/src/index.js +++ b/src/index.js @@ -67,7 +67,8 @@ const DEFAULT_CONFIG = { text: , icon: , route: `/${ROUTE_WORKER_VOUCHER_ASSIGNMENT}`, - filter: (rights) => [VOUCHER_RIGHT_SEARCH].some((right) => rights.includes(right)), + filter: (rights, config) => config.genericVoucherEnabled + && [VOUCHER_RIGHT_SEARCH].some((right) => rights.includes(right)), }, ], 'admin.MainMenu': [