Skip to content

Commit

Permalink
Prop validations (#66)
Browse files Browse the repository at this point in the history
* prop-validations added

* Props validations added and validation types created
  • Loading branch information
mcsmithers authored and lpatmo committed Apr 27, 2019
1 parent 79915eb commit c8d179b
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 5 deletions.
6 changes: 6 additions & 0 deletions imports/ui/components/apply.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { timezones } from '/lib/data/timezones';
import { Alert, Card, Button, Form } from 'react-bootstrap';
import { EMAIL_REGEX } from '/imports/constants/regex';
import { Meteor } from 'meteor/meteor';
import { PropTypes } from 'prop-types';

class Apply extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -211,4 +212,9 @@ class Apply extends React.Component {
}
}

Apply.propTypes = {
// We can check optional and required types here
history: PropTypes.array,
};

export default Apply;
6 changes: 6 additions & 0 deletions imports/ui/components/board/board.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Container } from 'react-bootstrap';
import Column from './column';
import '/imports/ui/styles/_board.scss';
import { categories } from '/lib/data/categories.js';
import { PropTypes } from 'prop-types';

class Board extends React.Component {
constructor(props) {
Expand All @@ -26,4 +27,9 @@ class Board extends React.Component {
}
}

Board.propTypes = {
// We can check optional and required types here
entries: PropTypes.array,
};

export default Board;
7 changes: 7 additions & 0 deletions imports/ui/components/board/column.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import Entry from './entry';
import { PropTypes } from 'prop-types';

class Column extends React.Component {
render() {
Expand All @@ -18,4 +19,10 @@ class Column extends React.Component {
}
}

Column.propTypes = {
// We can check optional and required types here
entries: PropTypes.array,
heading: PropTypes.string,
};

export default Column;
7 changes: 7 additions & 0 deletions imports/ui/components/board/entry.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import FavoriteIcon from '@material-ui/icons/Favorite';
// import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder';
import { PropTypes } from 'prop-types';

function Entry(props) {
const { timezone, lookingFor, oneLineIntro } = props;
Expand All @@ -16,4 +17,10 @@ function Entry(props) {
);
}

Entry.propTypes = {
// We can check optional and required types here
timezone: PropTypes.string,
lookingFor: PropTypes.array,
oneLineIntro: PropTypes.string,
};
export default Entry;
8 changes: 8 additions & 0 deletions imports/ui/components/dashboard/dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import DashboardSidebar from './dashboard_sidebar';
import MatchesSection from './matches_section';
import DashboardCardsSection from './dashboard_cards_section';
import { categories } from '/lib/data/categories.js';
import { PropTypes } from 'prop-types';

const sectionTargets = {
//see: categories.js for numbers
Expand Down Expand Up @@ -95,4 +96,11 @@ class Dashboard extends Component {
}
}

Dashboard.propTypes = {
entries: PropTypes.array,
handleCategoryChange: PropTypes.element,
currentUserName: PropTypes.string,
ownEntries: PropTypes.element,
};

export default Dashboard;
7 changes: 7 additions & 0 deletions imports/ui/components/dashboard/dashboard_cards_section.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import { CardColumns, Card, Collapse } from 'react-bootstrap';
import MatchCard from './match_card';
import { PropTypes } from 'prop-types';

class DashboardCardsSection extends Component {
render() {
Expand Down Expand Up @@ -38,4 +39,10 @@ class DashboardCardsSection extends Component {
}
}

DashboardCardsSection.propTypes = {
section: PropTypes.element,
visibility: PropTypes.bool,
entries: PropTypes.array,
};

export default DashboardCardsSection;
7 changes: 7 additions & 0 deletions imports/ui/components/dashboard/dashboard_sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import { ListGroup } from 'react-bootstrap';
import { PropTypes } from 'prop-types';

class DashboardSidebar extends Component {
constructor(props) {
Expand Down Expand Up @@ -41,4 +42,10 @@ class DashboardSidebar extends Component {
}
}

DashboardSidebar.propTypes = {
onVisibilityChange: PropTypes.boolean,
sections: PropTypes.element,
currentUserName: PropTypes.string,
};

export default DashboardSidebar;
8 changes: 8 additions & 0 deletions imports/ui/components/dashboard/match_card.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import { Card, Dropdown, ButtonGroup, Button } from 'react-bootstrap';
import '/imports/ui/styles/_cards.scss';
import { PropTypes } from 'prop-types';

class MatchCard extends Component {
constructor(props) {
Expand Down Expand Up @@ -38,4 +39,11 @@ class MatchCard extends Component {
}
}

MatchCard.propTypes = {
oneLineIntro: PropTypes.string,
lookingFor: PropTypes.string,
ownCard: PropTypes.boolean,
timezone: PropTypes.string,
};

export default MatchCard;
5 changes: 5 additions & 0 deletions imports/ui/components/dashboard/matches_section.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Card, Nav, Tab } from 'react-bootstrap';
import MatchCard from './match_card';
import { PropTypes } from 'prop-types';

const MatchesSection = props => {
const { ownEntries } = props;
Expand Down Expand Up @@ -42,4 +43,8 @@ const MatchesSection = props => {
);
};

MatchesSection.propTypes = {
ownEntries: PropTypes.element,
};

export default MatchesSection;
6 changes: 6 additions & 0 deletions imports/ui/components/moderator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Container, Row, Col } from 'react-bootstrap';
import { AuthContext } from './hoc/AuthProvider';
import BoardContainer from '/imports/ui/containers/board.jsx';
import { PropTypes } from 'prop-types';

class Moderator extends React.Component {
constructor(props) {
Expand All @@ -28,4 +29,9 @@ class Moderator extends React.Component {
}

Moderator.contextType = AuthContext;

Moderator.propTypes = {
user: PropTypes.object,
};

export default Moderator;
8 changes: 8 additions & 0 deletions imports/ui/components/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React from 'react';
import { Link } from 'react-router-dom';
import { Navbar, Nav, Button, Container } from 'react-bootstrap';
import { Meteor } from 'meteor/meteor';
import { PropTypes } from 'prop-types';
import { AuthContext } from './hoc/AuthProvider';


class NavigationBar extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -61,5 +63,11 @@ class NavigationBar extends React.Component {
}
}


NavigationBar.propTypes = {
user: PropTypes.object,
children: PropTypes.object,
};

NavigationBar.contextType = AuthContext;
export default NavigationBar;
6 changes: 6 additions & 0 deletions imports/ui/components/set_password.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import { Alert, Container, Button, Form, Row, Col } from 'react-bootstrap';
import { Accounts } from 'meteor/accounts-base';
import { PropTypes } from 'prop-types';

class SetPassword extends Component {
constructor(props) {
Expand Down Expand Up @@ -119,4 +120,9 @@ class SetPassword extends Component {
}
}

SetPassword.propTypes = {
match: PropTypes.boolean,
history: PropTypes.array,
};

export default SetPassword;
18 changes: 13 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"lodash": "4.17.11",
"meteor-node-stubs": "^0.4.1",
"popper.js": "1.14.4",
"prop-types": "^15.7.2",
"react": "^16.7.0",
"react-bootstrap": "^1.0.0-beta.4",
"react-dom": "^16.7.0",
Expand Down

0 comments on commit c8d179b

Please sign in to comment.