diff --git a/api/package.json b/api/package.json index 956f2fd..965fb42 100644 --- a/api/package.json +++ b/api/package.json @@ -22,7 +22,7 @@ "http-errors": "~1.6.3", "if-env": "^1.0.4", "isomorphic-unfetch": "^3.0.0", - "lodash": "^4.17.20", + "lodash": "^4.17.21", "mongodb": "^3.3.2", "mongoose": "^5.7.5", "morgan": "~1.9.1", diff --git a/api/src/api/members.js b/api/src/api/members.js index 1bdf1ab..ea31023 100644 --- a/api/src/api/members.js +++ b/api/src/api/members.js @@ -68,6 +68,8 @@ router.get( }), ); +// Create a new member +// Requires Director Level router.post( '/', requireDirector, diff --git a/api/src/utils/user-utils.js b/api/src/utils/user-utils.js index d56fbc1..6afbc0d 100644 --- a/api/src/utils/user-utils.js +++ b/api/src/utils/user-utils.js @@ -28,8 +28,8 @@ const nonEditableFields = [ const validationFields = { email: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/, phone: /^[0-9]{10}$/, - gradYear: /^\d{4}/, - generationYear: /^\d{4}/, + gradYear: /^\d{4}$/, + generationYear: /^\d{4}$/, }; const getViewableFields = (currentUser, memberId) => { diff --git a/api/yarn.lock b/api/yarn.lock index f61506a..ca2584b 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -3309,10 +3309,10 @@ lodash.sortby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= -lodash@^4.17.14, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.3: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== +lodash@^4.17.14, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.3: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== lolex@^5.0.0: version "5.1.2" diff --git a/client/src/App.js b/client/src/App.js index a6b1710..8056346 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -18,11 +18,13 @@ function App() { useEffect(() => { const userAuth = async () => { const resp = await getUserAuth(); - if (!resp.error) setUser(resp.data.result); + if (!resp.error) setUser(resp?.data?.result); }; userAuth(); }, [location]); + // TODO: Create user context and remove prop drilling + return (
{user && } @@ -33,7 +35,7 @@ function App() { - + {user ? : } @@ -41,7 +43,7 @@ function App() { - + diff --git a/client/src/components/EditableAttribute/DateAttribute.js b/client/src/components/EditableAttribute/DateAttribute.js index 5918f54..0277435 100644 --- a/client/src/components/EditableAttribute/DateAttribute.js +++ b/client/src/components/EditableAttribute/DateAttribute.js @@ -11,6 +11,7 @@ const DateAttribute = ({ isDisabled = false, className = '', onChange, + isRequired = false, }) => { const onValueChange = (date) => { onChange(date, attributeLabel); @@ -24,6 +25,7 @@ const DateAttribute = ({ onChange={onValueChange} selected={value} disabled={isDisabled} + required={isRequired} />
); @@ -35,6 +37,7 @@ DateAttribute.propTypes = { isDisabled: PropTypes.bool, className: PropTypes.string, onChange: PropTypes.func.isRequired, + isRequired: PropTypes.bool, }; export default DateAttribute; diff --git a/client/src/components/EditableAttribute/TextAttribute.js b/client/src/components/EditableAttribute/TextAttribute.js index 0d7b563..e69afc9 100644 --- a/client/src/components/EditableAttribute/TextAttribute.js +++ b/client/src/components/EditableAttribute/TextAttribute.js @@ -10,6 +10,7 @@ const TextAttribute = ({ isDisabled = false, className = '', onChange, + isRequired = false, }) => { const onValueChange = (e) => { onChange(e.target.value, attributeLabel); @@ -23,6 +24,7 @@ const TextAttribute = ({ value={value} onChange={onValueChange} disabled={isDisabled} + required={isRequired} /> ); @@ -33,6 +35,7 @@ TextAttribute.propTypes = { type: PropTypes.string, attributeLabel: PropTypes.string, isDisabled: PropTypes.bool, + isRequired: PropTypes.bool, className: PropTypes.string, onChange: PropTypes.func.isRequired, }; diff --git a/client/src/components/navbar/Navbar.js b/client/src/components/navbar/Navbar.js index 44c2002..2cc0cf0 100644 --- a/client/src/components/navbar/Navbar.js +++ b/client/src/components/navbar/Navbar.js @@ -3,8 +3,8 @@ import { Link, NavLink } from 'react-router-dom'; import PropTypes from 'prop-types'; import '../../css/Navbar.css'; - import ProfileDropdown from '../ProfileDropdown/ProfileDropdown'; +import { levelEnum } from '../../utils/consts'; import * as Routes from '../../routes'; /** @@ -19,6 +19,11 @@ const Navbar = ({ user }) => (