Skip to content

Commit

Permalink
Merge pull request #25 from openimis/feature/OM-122
Browse files Browse the repository at this point in the history
OM-122: make generic vouchers configurable
  • Loading branch information
jdolkowski authored Feb 14, 2024
2 parents 213a5db + 376e1a6 commit 564858c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__.
16 changes: 13 additions & 3 deletions src/components/VoucherAcquirementForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 (
<>
Expand All @@ -36,9 +43,11 @@ function VoucherAcquirementForm() {
</Grid>
</Grid>
<Divider />
{ genericVoucherEnabled && (
<Grid className={classes.item}>
<Typography>{formatMessage('workerVoucher.VoucherAcquirementForm.subtitle')}</Typography>
</Grid>
)}
<Divider />
<Grid container>
<Grid item xs={3} className={classes.item}>
Expand All @@ -48,6 +57,7 @@ function VoucherAcquirementForm() {
nullLabel="workerVoucher.acquirement.method.NONE"
acquirementMethod={acquirementMethod}
setAcquirementMethod={setAcquirementMethod}
readOnly={!genericVoucherEnabled}
required
withNull
withLabel
Expand All @@ -61,7 +71,7 @@ function VoucherAcquirementForm() {
<Grid container>
<Grid xs={12}>
<Paper className={classes.paper}>
{acquirementMethod === ACQUIREMENT_METHOD.GENERIC_VOUCHER && (
{genericVoucherEnabled && acquirementMethod === ACQUIREMENT_METHOD.GENERIC_VOUCHER && (
<VoucherAcquirementGenericVoucher />
)}
{acquirementMethod === ACQUIREMENT_METHOD.SPECIFIC_WORKER && (
Expand Down
4 changes: 4 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const DEFAULT_CONFIG = {
text: <FormattedMessage module="workerVoucher" id="menu.voucherAssignment" />,
icon: <GroupAddIcon />,
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': [
Expand Down

0 comments on commit 564858c

Please sign in to comment.