Skip to content

Commit

Permalink
Merge pull request #93 from openimis/bugfix/OP-1906
Browse files Browse the repository at this point in the history
OP-1906: Added refresh for tabs in PH view
  • Loading branch information
delcroip authored Oct 7, 2024
2 parents 24ae670 + 07a8406 commit 2e60818
Show file tree
Hide file tree
Showing 5 changed files with 486 additions and 47 deletions.
34 changes: 27 additions & 7 deletions src/components/PolicyHolderContributionPlanBundlesTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "../constants";
import PolicyHolderContributionPlanBundleSearcher from "./PolicyHolderContributionPlanBundleSearcher";
import CreatePolicyHolderContributionPlanBundleDialog from "../dialogs/CreatePolicyHolderContributionPlanBundleDialog";
import { connect } from "react-redux";

class PolicyHolderContributionPlanBundlesTabLabel extends Component {
render() {
Expand All @@ -29,12 +30,9 @@ class PolicyHolderContributionPlanBundlesTabLabel extends Component {
}
}

class PolicyHolderContributionPlanBundlesTabPanel extends Component {
constructor(props) {
super(props);
this.state = {
reset: 0
}
class PolicyHolderContributionPlanBundlesTab extends Component {
state = {
reset: 0,
}

onSave = () => {
Expand All @@ -43,6 +41,18 @@ class PolicyHolderContributionPlanBundlesTabPanel extends Component {
}));
}

componentDidUpdate(prevProps) {
if (!prevProps.created && this.props.created) {
this.onSave();
}
if (!prevProps.updated && this.props.updated) {
this.onSave();
}
if (!prevProps.replaced && this.props.replaced) {
this.onSave();
}
}

render() {
const { rights, value, isTabsEnabled, policyHolder } = this.props;
return (
Expand All @@ -66,7 +76,8 @@ class PolicyHolderContributionPlanBundlesTabPanel extends Component {
<Grid item>
<CreatePolicyHolderContributionPlanBundleDialog
policyHolder={policyHolder}
onSave={this.onSave}
onSave={() => {}}
tabView
/>
</Grid>
</Grid>
Expand All @@ -85,6 +96,15 @@ class PolicyHolderContributionPlanBundlesTabPanel extends Component {
}
}

const mapStateToProps = (state) => ({
created: !!state.policyHolder ? state.policyHolder.policyholderCreatePolicyholdercontributionplanbundleResp : false,
updated: !!state.policyHolder ? state.policyHolder.policyholderReplacePolicyholdercontributionplanbundleResp : false,
replaced: !!state.policyHolder ? state.policyHolder.policyholderUpdatePolicyholdercontributionplanbundleResp : false,
});


const PolicyHolderContributionPlanBundlesTabPanel = connect(mapStateToProps)(PolicyHolderContributionPlanBundlesTab)

export {
PolicyHolderContributionPlanBundlesTabLabel,
PolicyHolderContributionPlanBundlesTabPanel
Expand Down
31 changes: 25 additions & 6 deletions src/components/PolicyHolderInsureesTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import PolicyHolderInsureeSearcher from "./PolicyHolderInsureeSearcher";
import { POLICYHOLDERINSUREE_TAB_VALUE } from "../constants"
import CreatePolicyHolderInsureeDialog from "../dialogs/CreatePolicyHolderInsureeDialog";
import { connect } from "react-redux";

class PolicyHolderInsureesTabLabel extends Component {
render() {
Expand All @@ -30,12 +31,9 @@ class PolicyHolderInsureesTabLabel extends Component {
}
}

class PolicyHolderInsureesTabPanel extends Component {
constructor(props) {
super(props);
this.state = {
reset: 0
}
class PolicyHolderInsureesTab extends Component {
state = {
reset: 0,
}

onSave = () => {
Expand All @@ -44,6 +42,18 @@ class PolicyHolderInsureesTabPanel extends Component {
}));
}

componentDidUpdate(prevProps) {
if (!prevProps.created && this.props.created) {
this.onSave();
}
if (!prevProps.updated && this.props.updated) {
this.onSave();
}
if (!prevProps.replaced && this.props.replaced) {
this.onSave();
}
}

render() {
const { rights, value, isTabsEnabled, policyHolder } = this.props;
return (
Expand Down Expand Up @@ -100,6 +110,15 @@ class PolicyHolderInsureesTabPanel extends Component {
}
}

const mapStateToProps = (state) => ({
created: !!state.policyHolder ? state.policyHolder.policyholderCreatePolicyholderinsureeResp : false,
updated: !!state.policyHolder ? state.policyHolder.policyholderUpdatePolicyholderinsureeResp : false,
replaced: !!state.policyHolder ? state.policyHolder.policyholderReplacePolicyholderinsureeResp : false,
});

const PolicyHolderInsureesTabPanel = connect(mapStateToProps)(PolicyHolderInsureesTab)


export {
PolicyHolderInsureesTabLabel,
PolicyHolderInsureesTabPanel
Expand Down
12 changes: 2 additions & 10 deletions src/components/PolicyHolderUserSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,9 @@ class PolicyHolderUserSearcher extends Component {
`
: "",
];
if (predefinedPolicyHolderId === null) {
result.push((policyHolderUser) => (
<PolicyHolderPicker
value={
!!policyHolderUser.policyHolder && policyHolderUser.policyHolder
}
withLabel={false}
readOnly
/>
!!policyHolderUser.policyHolder ? `${policyHolderUser.policyHolder.code} - ${policyHolderUser.policyHolder.tradeName}` : ''
));
}
result.push(
(policyHolderUser) =>
!!policyHolderUser.dateValidFrom
Expand Down Expand Up @@ -379,4 +371,4 @@ export default withModulesManager(
injectIntl(
connect(mapStateToProps, mapDispatchToProps)(PolicyHolderUserSearcher)
)
);
);
29 changes: 26 additions & 3 deletions src/components/PolicyHolderUsersTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { POLICYHOLDERUSER_TAB_VALUE } from "../constants"
import PolicyHolderUserSearcher from "./PolicyHolderUserSearcher";
import CreatePolicyHolderUserDialog from "../dialogs/CreatePolicyHolderUserDialog";
import { connect } from "react-redux";

class PolicyHolderUsersTabLabel extends Component {
render() {
Expand All @@ -32,15 +33,28 @@ class PolicyHolderUsersTabLabel extends Component {
}
}

class PolicyHolderUsersTabPanel extends Component {
class PolicyHolderUsersTab extends Component {
state = {
reset: 0
reset: 0,
}

onSave = () =>
onSave = () => {
this.setState(state => ({
reset: state.reset + 1
}));
}

componentDidUpdate(prevProps) {
if (!prevProps.created && this.props.created) {
this.onSave();
}
if (!prevProps.updated && this.props.updated) {
this.onSave();
}
if (!prevProps.replaced && this.props.replaced) {
this.onSave();
}
}

render() {
const { rights, value, isTabsEnabled, policyHolder } = this.props;
Expand Down Expand Up @@ -91,6 +105,15 @@ class PolicyHolderUsersTabPanel extends Component {
}
}

const mapStateToProps = (state) => ({
created: !!state.policyHolder ? state.policyHolder.policyholderCreatePolicyholderuserResp : false,
updated: !!state.policyHolder ? state.policyHolder.policyholderUpdatePolicyholderuserResp : false,
replaced: !!state.policyHolder ? state.policyHolder.policyholderReplacePolicyholderuserResp : false,
});

const PolicyHolderUsersTabPanel = connect(mapStateToProps)(PolicyHolderUsersTab)


export {
PolicyHolderUsersTabLabel,
PolicyHolderUsersTabPanel
Expand Down
Loading

0 comments on commit 2e60818

Please sign in to comment.