From af0023c29030b265d80bf9064fd03e2029e7acd7 Mon Sep 17 00:00:00 2001 From: olewandowski1 Date: Wed, 29 Nov 2023 10:19:20 +0100 Subject: [PATCH] OM-84: voucher acquirement page init, method pciker --- src/components/VoucherAcquirementForm.js | 69 +++++++++++++++++++ src/constants.js | 9 +++ src/pages/VoucherAcquirementPage.js | 25 ++++++- src/pages/VouchersPage.js | 2 +- src/pickers/VoucherAcquirementMethodPicker.js | 32 +++++++++ src/translations/en.json | 9 ++- 6 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 src/components/VoucherAcquirementForm.js create mode 100644 src/pickers/VoucherAcquirementMethodPicker.js diff --git a/src/components/VoucherAcquirementForm.js b/src/components/VoucherAcquirementForm.js new file mode 100644 index 0000000..da27e1c --- /dev/null +++ b/src/components/VoucherAcquirementForm.js @@ -0,0 +1,69 @@ +import React, { useState } from 'react'; + +import { + Divider, + Grid, + Paper, + Typography, +} from '@material-ui/core'; +import { makeStyles } from '@material-ui/styles'; + +import { useModulesManager, useTranslations } from '@openimis/fe-core'; +import { MODULE_NAME } from '../constants'; +import VoucherAcquirementMethodPicker from '../pickers/VoucherAcquirementMethodPicker'; + +export const useStyles = makeStyles((theme) => ({ + paper: { ...theme.paper.paper, margin: '10px 0 0 0' }, + paperHeaderTitle: theme.paper.title, + tableTitle: theme.table.title, + item: theme.paper.item, + fullHeight: { + height: '100%', + }, +})); + +function VoucherAcquirementForm() { + const modulesManager = useModulesManager(); + const classes = useStyles(); + const { formatMessage } = useTranslations(MODULE_NAME, modulesManager); + const [acquirementMethod, setAcquirementMethod] = useState(null); + + return ( + + + + + + + {formatMessage('workerVoucher.menu.voucherAcquirement')} + + + + + + + {formatMessage('workerVoucher.VoucherAcquirementForm.subtitle')} + + + + + + + + + + + + + ); +} + +export default VoucherAcquirementForm; diff --git a/src/constants.js b/src/constants.js index 5c16078..6363ff4 100644 --- a/src/constants.js +++ b/src/constants.js @@ -18,6 +18,15 @@ const WORKER_VOUCHER_STATUS = { CLOSED: 'CLOSED', }; +const ACQUIREMENT_METHOD = { + GENERIC_VOUCHER: 'GENERIC_VOUCHER', + SPECIFIC_WORKER: 'SPECIFIC_WORKER', +}; + +export const ACQUIREMENT_METHOD_LIST = [ + ACQUIREMENT_METHOD.GENERIC_VOUCHER, ACQUIREMENT_METHOD.SPECIFIC_WORKER, +]; + export const WORKER_VOUCHER_STATUS_LIST = [ WORKER_VOUCHER_STATUS.AWAITING_PAYMENT, WORKER_VOUCHER_STATUS.UNASSIGNED, diff --git a/src/pages/VoucherAcquirementPage.js b/src/pages/VoucherAcquirementPage.js index 357c0d6..da99c5a 100644 --- a/src/pages/VoucherAcquirementPage.js +++ b/src/pages/VoucherAcquirementPage.js @@ -1,10 +1,29 @@ import React from 'react'; +import { useSelector } from 'react-redux'; + +import { makeStyles } from '@material-ui/styles'; + +import { Helmet, useModulesManager, useTranslations } from '@openimis/fe-core'; +import { MODULE_NAME, VOUCHER_RIGHT_SEARCH } from '../constants'; +import VoucherAcquirementForm from '../components/VoucherAcquirementForm'; + +export const useStyles = makeStyles((theme) => ({ + page: theme.page, +})); function VoucherAcquirementPage() { + const modulesManager = useModulesManager(); + const classes = useStyles(); + const { formatMessage } = useTranslations(MODULE_NAME, modulesManager); + const rights = useSelector((state) => (state.core?.user?.i_user?.rights ?? [])); + return ( -
- VoucherAcquirementPage -
+ rights.includes(VOUCHER_RIGHT_SEARCH) && ( +
+ + +
+ ) ); } diff --git a/src/pages/VouchersPage.js b/src/pages/VouchersPage.js index df17bf4..89a440e 100644 --- a/src/pages/VouchersPage.js +++ b/src/pages/VouchersPage.js @@ -20,7 +20,7 @@ function VouchersPage() { return ( rights.includes(VOUCHER_RIGHT_SEARCH) && (
- +
) diff --git a/src/pickers/VoucherAcquirementMethodPicker.js b/src/pickers/VoucherAcquirementMethodPicker.js new file mode 100644 index 0000000..edfdc69 --- /dev/null +++ b/src/pickers/VoucherAcquirementMethodPicker.js @@ -0,0 +1,32 @@ +import React from 'react'; + +import { ConstantBasedPicker } from '@openimis/fe-core'; +import { ACQUIREMENT_METHOD_LIST } from '../constants'; + +function VoucherAcquirementMethodPicker({ + label, + acquirementMethod, + setAcquirementMethod, + required, + withNull, + readOnly = false, + nullLabel, + withLabel, +}) { + return ( + setAcquirementMethod(method)} + label={label} + required={required} + withNull={withNull} + readOnly={readOnly} + nullLabel={nullLabel} + withLabel={withLabel} + /> + ); +} + +export default VoucherAcquirementMethodPicker; diff --git a/src/translations/en.json b/src/translations/en.json index 7e86570..21a4343 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2,7 +2,6 @@ "workerVoucher.menu.voucherList": "Voucher List", "workerVoucher.menu.voucherAcquirement": "Voucher Acquirement", "workerVoucher.menu.voucherAssignment": "Voucher Assignment", - "workerVoucher.vouchers": "Vouchers", "workerVoucher.searcherResultsTitle": "{workerVouchersTotalCount} Vouchers Found", "workerVoucher.code": "Code", "workerVoucher.employer": "Employer", @@ -26,6 +25,10 @@ "workerVoucher.status.CANCELED": "CANCELED", "workerVoucher.status.CLOSED": "CLOSED", "workerVoucher.VoucherDetailsPage.title": "Worker Voucher - {code}", - "workerVoucher.VoucherDetailsPanel.subtitle": "Voucher's General Information" - + "workerVoucher.VoucherDetailsPanel.subtitle": "Voucher's General Information", + "workerVoucher.VoucherAcquirementForm.subtitle": "Select voucher acquirement method", + "workerVoucher.acquirement.method": "Acquirement Method", + "workerVoucher.acquirement.method.NONE": "None", + "workerVoucher.acquirement.method.GENERIC_VOUCHER": "Generic Voucher", + "workerVoucher.acquirement.method.SPECIFIC_WORKER": "Specific Voucher" }