Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Commit

Permalink
fixed some last second bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxAltena committed Nov 14, 2018
1 parent ff8b076 commit db48961
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
15 changes: 12 additions & 3 deletions client/src/components/popups/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { connect } from "react-redux";
import PropTypes from "prop-types";
import { addDashboard, getCompanies } from "../../actions/companyActions";
import TextFieldGroup from "../common/TextField";
import isEmpty from "../../validation/is-empty";
import removeSpecial from "../../validation/remove-special";

class Dashboard extends Component {
Expand All @@ -24,7 +25,10 @@ class Dashboard extends Component {
};

componentDidMount = () => {
this.handleSelectClick(this.state.companyId);
const { companyId } = this.state;
if (!isEmpty(companyId)) {
this.handleSelectClick(companyId);
}
};

componentWillReceiveProps = nextProps => {
Expand Down Expand Up @@ -91,8 +95,13 @@ class Dashboard extends Component {
});

// Highlight item in list
const selectedItem = document.getElementById(companyId);
selectedItem.classList.add("selected");
if (!isEmpty(companyId)) {
const selectedItem = document.getElementById(companyId);

if (!isEmpty(selectedItem)) {
selectedItem.classList.add("selected");
}
}
};

renderCompanyList = () => {
Expand Down
4 changes: 2 additions & 2 deletions client/src/validation/remove-special.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const removeSpecial = value => {
var res = "";
for (var i = 0; i < lower.length; ++i) {
if (allowed.indexOf(lower[i]) > -1) {
res += value[i];
} else {
if (lower[i] !== upper[i] || lower[i].trim() === "") {
res += value[i];
}
} else {
res += value[i];
}
}
return res;
Expand Down
4 changes: 2 additions & 2 deletions validation/remove-special.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const removeSpecial = value => {
var res = "";
for (var i = 0; i < lower.length; ++i) {
if (allowed.indexOf(lower[i]) > -1) {
res += value[i];
} else {
if (lower[i] !== upper[i] || lower[i].trim() === "") {
res += value[i];
}
} else {
res += value[i];
}
}
return res;
Expand Down

0 comments on commit db48961

Please sign in to comment.