Skip to content

Commit

Permalink
Merge pull request #9 from openimis/hotfix/OMT_179_LGTM_fixes
Browse files Browse the repository at this point in the history
LGTM fixes
  • Loading branch information
xgill authored May 26, 2020
2 parents 7a0be26 + ec27bb7 commit 6c7fbcd
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openimis/fe-insuree",
"version": "1.2.0-rc1",
"version": "1.2.0-rc2",
"license": "AGPL-3.0-only",
"description": "openIMIS Frontend Insuree reference module",
"repository": "openimis/openimis-fe-insuree_js",
Expand Down
2 changes: 0 additions & 2 deletions src/components/EnquiryDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const styles = theme => ({

class EnquiryDialog extends Component {

state = { loading: false }

componentDidUpdate(prevProps, prevState, snapshot) {
if (prevProps.chfid !== this.props.chfid) {
this.props.fetchInsuree(this.props.modulesManager, this.props.chfid);
Expand Down
2 changes: 1 addition & 1 deletion src/components/InsureeCappedItemServiceLink.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, Fragment } from "react";
import React, { Component } from "react";
import { connect } from "react-redux";
import { injectIntl } from 'react-intl';
import { withTheme, withStyles } from "@material-ui/core/styles";
Expand Down
2 changes: 1 addition & 1 deletion src/components/InsureeFirstServicePoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class InsureeFirstServicePoint extends Component {
</Grid>
<Grid item xs={12} className={classes.details}>
<PublishedComponent
id="location.HealthFacilityFullPath"
pubRef="location.HealthFacilityFullPath"
hfid={insuree.healthFacility.id}
/>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/components/InsureeProfileLink.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, Fragment } from "react";
import React, { Component } from "react";
import { connect } from "react-redux";
import { injectIntl } from 'react-intl';
import { withTheme, withStyles } from "@material-ui/core/styles";
Expand Down
24 changes: 12 additions & 12 deletions src/pickers/InsureeChfIdPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ class InsureeChfIdPicker extends Component {

componentDidMount() {
if (this.props.value) {
this.setState({
search: !!this.props.value ? this.props.value.chfId : null,
selected: this.props.value,
});
this.setState((state, props) => ({
search: !!props.value ? props.value.chfId : null,
selected: props.value,
}));
}
}

componentDidUpdate(prevProps, prevState, snapshot) {
if (prevProps.reset !== this.props.reset) {
this.setState({
this.setState((state, props) => ({
...INIT_STATE,
search: !!this.props.value ? this.props.value.chfId : null,
selected: this.props.value
});
search: !!props.value ? props.value.chfId : null,
selected: props.value
}));
} else if (!_.isEqual(prevProps.insuree, this.props.insuree)) {
this.props.onChange(this.props.insuree, this.formatInsuree(this.props.insuree))
} else if (!_.isEqual(prevProps.value, this.props.value)) {
this.setState({
search: !!this.props.value ? this.props.value.chfId : null,
selected: this.props.value
});
this.setState((state, props) => ({
search: !!props.value ? props.value.chfId : null,
selected: props.value
}));
}
}

Expand Down
34 changes: 15 additions & 19 deletions src/pickers/InsureePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class RawFilter extends Component {
chfId: "",
lastName: "",
otherNames: "",
page: 0,
pageSize: 0,
afterCursor: null,
beforeCursor: null,
}

stateToFilters = () => {
Expand Down Expand Up @@ -100,18 +96,18 @@ class InsureePicker extends Component {

componentDidMount() {
if (this.props.value) {
this.setState({ selected: this.props.value });
this.setState((state, props) => ({ selected: props.value }));
}
}

componentDidUpdate(prevProps, prevState, snapshot) {
if (prevProps.reset !== this.props.reset) {
this.setState({
this.setState((state, props) => ({
...INIT_STATE,
selected: this.props.value
});
selected: props.value
}));
} else if (!_.isEqual(prevProps.value, this.props.value)) {
this.setState({ selected: this.props.value });
this.setState((state, props) => ({ selected: props.value }));
}
}

Expand Down Expand Up @@ -162,21 +158,21 @@ class InsureePicker extends Component {

onChangePage = (page, nbr) => {
if (nbr > this.state.page) {
this.setState(
{
page: this.state.page + 1,
this.setState((state, props) =>
({
page: state.page + 1,
beforeCursor: null,
afterCursor: this.props.insureesPageInfo.endCursor,
},
afterCursor: props.insureesPageInfo.endCursor,
}),
e => this.props.fetchInsurees(this.props.modulesManager, this.filtersToQueryParams())
)
} else if (nbr < this.state.page) {
this.setState(
{
page: this.state.page - 1,
beforeCursor: this.props.insureesPageInfo.startCursor,
this.setState((state, props) =>
({
page: state.page - 1,
beforeCursor: props.insureesPageInfo.startCursor,
afterCursor: null,
},
}),
e => this.props.fetchInsurees(this.props.modulesManager, this.filtersToQueryParams())
)
}
Expand Down

0 comments on commit 6c7fbcd

Please sign in to comment.