Skip to content

Commit

Permalink
OP-1822: disable selection in enquiry dialog (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
olewandowski1 authored Mar 1, 2024
1 parent 4827b5a commit a3d6bfd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
39 changes: 28 additions & 11 deletions src/components/EnquiryDialog.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useEffect, Fragment, useRef } from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { injectIntl } from "react-intl";

import { Dialog, Button, DialogActions, DialogContent } from "@material-ui/core";
import { makeStyles } from "@material-ui/styles";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { fetchInsuree } from "../actions";

import {
formatMessage,
formatMessageWithValues,
Expand All @@ -14,6 +15,7 @@ import {
withModulesManager,
withHistory,
} from "@openimis/fe-core";
import { fetchInsuree } from "../actions";
import InsureeSummary from "./InsureeSummary";

const useStyles = makeStyles(() => ({
Expand All @@ -22,14 +24,25 @@ const useStyles = makeStyles(() => ({
},
}));

const EnquiryDialog = (props) => {
const { intl, modulesManager, fetchInsuree, fetching, fetched, insuree, error, onClose, open, chfid, match } = props;
const EnquiryDialog = ({
intl,
modulesManager,
fetchInsuree,
fetching,
fetched,
insuree,
error,
onClose,
open,
chfId,
match,
}) => {
const classes = useStyles();
const prevMatchUrl = useRef(null);

useEffect(() => {
if (open && insuree?.id !== chfid) {
fetchInsuree(modulesManager, chfid);
if (open && insuree?.id !== chfId) {
fetchInsuree(modulesManager, chfId);
}

if (!!match?.url && match.url !== prevMatchUrl.current) {
Expand All @@ -39,8 +52,7 @@ const EnquiryDialog = (props) => {
if (!!match?.url) {
prevMatchUrl.current = match.url;
}

}, [open, chfid, match?.url]);
}, [open, chfId, match?.url]);

return (
<Dialog maxWidth="xl" fullWidth open={open} onClose={onClose}>
Expand All @@ -50,14 +62,19 @@ const EnquiryDialog = (props) => {
<Error
error={{
code: formatMessage(intl, "insuree", "notFound"),
detail: formatMessageWithValues(intl, "insuree", "chfidNotFound", { chfid }),
detail: formatMessageWithValues(intl, "insuree", "chfIdNotFound", { chfId }),
}}
/>
)}
{!fetching && insuree && (
<Fragment>
<InsureeSummary modulesManager={modulesManager} insuree={insuree} className={classes.summary} />
<Contributions contributionKey="insuree.EnquiryDialog" insuree={insuree} hideAddPolicyButton />
<Contributions
contributionKey="insuree.EnquiryDialog"
insuree={insuree}
disableSelection
hideAddPolicyButton
/>
</Fragment>
)}
</DialogContent>
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"insuree.link.cappedItemService": "Capped Items/Services",
"insuree.link.profile": "Profile",
"insuree.notFound": "Not Found",
"insuree.chfidNotFound": "No insuree with chfid {chfid} found.",
"insuree.chfIdNotFound": "No insuree with chfid {chfid} found.",
"insuree.noFSP": "First Service Point not registered.",
"insuree.FSP.title": "First Service Point",
"insuree.Insuree.searchCriteria": "Search Criteria",
Expand Down

0 comments on commit a3d6bfd

Please sign in to comment.