Skip to content

Commit

Permalink
BAH-4104 | Add. Show PurposeOfRequest in Consent Detail Panel
Browse files Browse the repository at this point in the history
mohan-13 committed Oct 8, 2024
1 parent 847b27b commit 66f9c46
Showing 3 changed files with 19 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/components/ConsentsListTable/ConsentDetailPanel.js
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ const consentArtefactDetailsComponent = (consentArtefacts) => {
</TableHead>
<TableBody>
{consentArtefacts.map((consentArtefact, index) => {
return (<TableRow>
return (<TableRow key={index}>
<TableCell>{consentArtefact.hipName}</TableCell>
<TableCell>{consentArtefact.status}</TableCell>
<TableCell>{formatDateString(consentArtefact.dateModified, true)}</TableCell>
@@ -86,9 +86,14 @@ const consentArtefactDetailsComponent = (consentArtefacts) => {
}


const ConsentDetailPanel = ({ consentDetail }) => {
const ConsentDetailPanel = ({ consentDetail, purposesOfUse }) => {
const classes = useStyles();
const consentStatus = consentDetail.status;
const getPurposeDisplayValue = (code) => {
const purpose = purposesOfUse.find(p => p.code === code);
return purpose ? purpose.display : code;
};

return (
<Grid container spacing={1} className={classes.detailPanel}>
<Grid item xs={6}>
@@ -101,6 +106,11 @@ const ConsentDetailPanel = ({ consentDetail }) => {
<strong>Requested Date Range:</strong> {getPermissionDateRangeText(consentDetail.permission)}
</Typography>
</Grid>
{consentDetail.purpose?.code &&
<Grid item xs={12}>
<strong>Purpose of Request:</strong> {getPurposeDisplayValue(consentDetail.purpose.code)}
</Grid>
}
<Grid item xs={12}>
{consentStatus === 'DENIED' && consentDeniedComponent(consentDetail.dateModified)}
{consentStatus === 'EXPIRED' && consentExpiredComponent(consentDetail.expiredDate)}
@@ -124,7 +134,8 @@ const ConsentDetailPanel = ({ consentDetail }) => {
};

ConsentDetailPanel.propTypes = {
consentDetail: PropTypes.object.isRequired
consentDetail: PropTypes.object.isRequired,
purposesOfUse: PropTypes.array
};

export default ConsentDetailPanel;
7 changes: 4 additions & 3 deletions src/components/ConsentsListTable/ConsentsListTable.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ const useStyles = makeStyles(theme => ({
}
}));

const ConsentsListTable = ({ loadConsents, consentsList, loading }) => {
const ConsentsListTable = ({ loadConsents, consentsList, loading, purposesOfUse }) => {
const classes = useStyles();
const [refreshCounter, setRefreshCounter] = useState(0);
useEffect(() => {
@@ -138,7 +138,7 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => {
}
]}
detailPanel={rowData => (
<ConsentDetailPanel consentDetail={rowData.consentDetail}/>
<ConsentDetailPanel consentDetail={rowData.consentDetail} purposesOfUse={purposesOfUse}/>
)}
/>
</div>
@@ -161,7 +161,8 @@ const consentShape = PropTypes.shape({
ConsentsListTable.propTypes = {
loadConsents: PropTypes.func.isRequired,
consentsList: PropTypes.arrayOf(consentShape).isRequired,
loading: PropTypes.bool
loading: PropTypes.bool,
purposesOfUse: PropTypes.array
};

ConsentsListTable.defaultProps = {
1 change: 1 addition & 0 deletions src/components/ConsentsListTable/LoadConsentsContainer.js
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import getNestedObject from '../../utils/getNestedObject';
const mapStateToProps = (state) => ({
consentsList: getNestedObject(state, 'loadConsents.consentsList'),
loading: getNestedObject(state, 'loadConsents.loading'),
purposesOfUse: getNestedObject(state, 'configValueSets.purposesOfUse'),
});

const mapDispatchToProps = {

0 comments on commit 66f9c46

Please sign in to comment.