diff --git a/client/components/About.js b/client/components/About.js new file mode 100644 index 000000000..bed14f40e --- /dev/null +++ b/client/components/About.js @@ -0,0 +1,51 @@ +import React from 'react' +import Button from '@material-ui/core/Button' +import Dialog from '@material-ui/core/Dialog' +import DialogActions from '@material-ui/core/DialogActions' +import DialogContent from '@material-ui/core/DialogContent' +import DialogContentText from '@material-ui/core/DialogContentText' +import DialogTitle from '@material-ui/core/DialogTitle' +import CssBaseline from '@material-ui/core/CssBaseline' + +class About extends React.Component { + state = { + open: true + } + + handleClickOpen = () => { + this.setState({ open: true }) + } + + handleClose = () => { + this.setState({ open: false }) + } + + render () { + return ( + + + + + {"Section under development."} + + + + The functionality of this section has not been developed yet. We expect to have it for November 2018. Thanks for your understanding. + + + + + + + + ) + } +} + +export default About diff --git a/client/components/Browse.js b/client/components/Browse.js new file mode 100644 index 000000000..2231b1f8b --- /dev/null +++ b/client/components/Browse.js @@ -0,0 +1,14 @@ +import React from 'react' +import UserList from './UserList' +import CssBaseline from '@material-ui/core/CssBaseline' + +const Browse = () => { + return ( + + + + + ) +} + +export default Browse diff --git a/client/components/Contact.js b/client/components/Contact.js new file mode 100644 index 000000000..268efeaee --- /dev/null +++ b/client/components/Contact.js @@ -0,0 +1,52 @@ +import React from 'react' +import Button from '@material-ui/core/Button' +import Dialog from '@material-ui/core/Dialog' +import DialogActions from '@material-ui/core/DialogActions' +import DialogContent from '@material-ui/core/DialogContent' +import DialogContentText from '@material-ui/core/DialogContentText' +import DialogTitle from '@material-ui/core/DialogTitle' +import CssBaseline from '@material-ui/core/CssBaseline' + +class Contact extends React.Component { + state = { + open: true + } + + handleClickOpen = () => { + this.setState({ open: true }) + } + + handleClose = () => { + this.setState({ open: false }) + } + + render () { + return ( + + + + + + {"Section under development."} + + + + The functionality of this section has not been developed yet. We expect to have it for November 2018. Thanks for your understanding. + + + + + + + + ) + } +} + +export default Contact diff --git a/client/components/DescendentsTree.js b/client/components/DescendentsTree.js new file mode 100644 index 000000000..9a1cb06ea --- /dev/null +++ b/client/components/DescendentsTree.js @@ -0,0 +1,258 @@ +import React, { Component } from 'react' +import {graphql, compose} from 'react-apollo' +import {getDescendentsQuery} from '../queries/queries' + +// Materia UI + +import { withStyles } from '@material-ui/core/styles' +import Card from '@material-ui/core/Card' +import CardActionArea from '@material-ui/core/CardActionArea' +import CardActions from '@material-ui/core/CardActions' +import CardContent from '@material-ui/core/CardContent' +import CardMedia from '@material-ui/core/CardMedia' +import Typography from '@material-ui/core/Typography' +import Grid from '@material-ui/core/Grid' + +// Material UI Nestled Lists +import ListSubheader from '@material-ui/core/ListSubheader'; +import List from '@material-ui/core/List'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemIcon from '@material-ui/core/ListItemIcon'; +import ListItemText from '@material-ui/core/ListItemText'; +import Collapse from '@material-ui/core/Collapse'; +import ExpandLess from '@material-ui/icons/ExpandLess'; +import ExpandMore from '@material-ui/icons/ExpandMore'; +import StarBorder from '@material-ui/icons/StarBorder'; + +// Images +import PortraitImage from '../img/portrait.jpg' + +const styles = theme => ({ + card: { + maxWidth: 300, + minWidth: 300, + paddingTop: '30' + }, + media: { + height: 0, + paddingTop: '56.25%', // 16:9, + marginTop: '30', + minWidth: 300 + }, + typography: { + maxWidth: 345, + minWidth: 300, + paddingTop: '30' + }, + appBar: { + position: 'relative' + }, + flex: { + flex: 1 + }, + grid: { + paddingTop: '30', + marginTop: 30 + }, + list: { + width: '80%', + marginLeft: '10%', + marginTop: 25 + }, + button: { + margin: theme.spacing.unit, + marginTop: theme.spacing.unit * 3 + }, + nested: { + paddingLeft: theme.spacing.unit * 4, + }, +}) + +class DescendentsTree extends Component { + + constructor (props) { + super(props) + + this.state = { + id: '', + open: true + } + } + + handleClick = () => { + this.setState(state => ({ open: !state.open })); +}; + + displayIcons(amount) { + + switch (amount) { + case 1: return ( +
+ + + +
+ ) + case 2: return ( +
+ + + + + + +
+ ) + case 3: return ( +
+ + + + + + + + + +
+ ) + default: return(
) + } + } + + displayNestedListItems(node, level) { + + const { classes } = this.props + return node.descendents.map(descendent => { + return ( +
+ + {this.displayIcons(level)} + + + + + + {descendent.alias} + + + + + + + + + + + {this.displayNestedList(descendent, level)} +
+ ) + } + ) + } + + displayNestedList(descendent, level) { + const primaryText = "Children of " + descendent.alias + if (descendent.descendents !== undefined) { + if (descendent.descendents.length > 0) { + return( + + { + this.setState(state => ({ [descendent.alias]: !state[descendent.alias] })); + } + }> + + {this.state[descendent.alias] ? : } + + + {this.displayNestedListItems(descendent, level + 1)} + + + ) + } else { + return (
) + } + } + } + + + displayTopList () { + let data = this.props.data + const { classes } = this.props + + if (data.loading) { + return (
Loading Descendents...
) + } else { + if (data.users_Descendents === undefined) { + return (
No Descendents to Display
) + } else { + return data.users_Descendents.map(descendent => { + return ( +
+ + + {this.displayIcons(1)} + + + + + + {descendent.alias} + + + + + + + + + + + + {this.displayNestedList(descendent, 1)} + +
+ ) + }) + } + } + } + + render () { + const { classes } = this.props + return ( +
+ } + className={classes.list} + > + {this.displayTopList()} + +
+ ) + } +} + +export default compose( + graphql(getDescendentsQuery, { // What follows is the way to pass a parameter to a query. + options: (props) => { + return { + variables: { + name: 'getDescendentsQuery', + id: props.userId + } + } + }}), + withStyles(styles) +)(DescendentsTree) // This technique binds more than one query to a single component. diff --git a/client/components/Home.js b/client/components/Home.js new file mode 100644 index 000000000..bb829f8dd --- /dev/null +++ b/client/components/Home.js @@ -0,0 +1,104 @@ +import React, { Component } from 'react' +import { compose } from 'recompose' +import { withStyles } from '@material-ui/core/styles' +import Grid from '@material-ui/core/Grid' +import Typography from '@material-ui/core/Typography' +import CssBaseline from '@material-ui/core/CssBaseline' + +const styles = theme => ({ + root: { + flexGrow: 1, + padding: 100 + }, + grid: { + margin: theme.spacing.unit, + width: '50%' + }, + typography: { + width: '100%', + marginTop: 20, + marginBottom: 20 + }, + '@global': { + body: { + backgroundColor: theme.palette.common.white + } + }, + layout: { + width: 'auto', + marginLeft: theme.spacing.unit * 3, + marginRight: theme.spacing.unit * 3, + [theme.breakpoints.up(900 + theme.spacing.unit * 3 * 2)]: { + width: 900, + marginLeft: 'auto', + marginRight: 'auto' + } + }, + heroContent: { + maxWidth: 600, + margin: '0 auto', + padding: `${theme.spacing.unit * 8}px 0 ${theme.spacing.unit * 6}px` + } +}) + +class Home extends Component { + + render () { + const { classes } = this.props + return ( + + +
+
+ + Collaborate. Innovate. Evolve. + + + Welcome to Advanced Algos Users Module + +
+
+ + + + + Intro + + + This module is responsible for managing users across the Advanced Algos system. Here you can browse the Users Directory, search for users and get to their profiles. You can create your own User profile if you sign up, or manage it if you already have one by logging in. + + + Development Status + + + This module is is currently under development. Implementation started 1st of September 2018 and this is the result of the 3rd sprint of 2 weeks of work each. + + + What can you do? + + + Currently you can use the Browse section to list all registered users. At the Search page you can searh for users by name. Clicking on View Profile you can see some more info about that user. You can signup with your Github account and manage your profile information while logged in. While loggedin, you can edit your profile info, define your referrer and view your descendants. You will find all features under develpment with a dialog indicating it is not ready. + + + + + +
+ + ) + } +} + +export default compose( + withStyles(styles) +)(Home) diff --git a/client/components/LoggedInUser.js b/client/components/LoggedInUser.js new file mode 100644 index 000000000..933394e43 --- /dev/null +++ b/client/components/LoggedInUser.js @@ -0,0 +1,135 @@ +import React, { Component } from 'react' +import {graphql, compose} from 'react-apollo' +import {getUserByAuthIdQuery} from '../queries/queries' +import { withStyles } from '@material-ui/core/styles' +import classNames from 'classnames' + +import Button from '@material-ui/core/Button' +import IconButton from '@material-ui/core/IconButton' + +// icons +import UserIcon from '@material-ui/icons/Person' +import { Link } from 'react-router-dom' + +const UserLink = props => + +const styles = theme => ({ + root: { + flexGrow: 1 + }, + flex: { + flexGrow: 1, + marginLeft: 30 + }, + menuButton: { + marginLeft: -12, + marginRight: 20 + }, + cssRoot: { + color: '#FFFFFF', + backgroundColor: theme.palette.secondary, + '&:hover': { + backgroundColor: theme.palette.dark + }, + whiteSpace: 'nowrap', + paddingRight: 2 * theme.spacing.unit, + paddingLeft: 2 * theme.spacing.unit + }, + button: { + margin: theme.spacing.unit + }, + leftIcon: { + marginRight: theme.spacing.unit + }, + rightIcon: { + marginLeft: theme.spacing.unit + }, + iconSmall: { + fontSize: 20 + } +}) + +class LoggedInUser extends Component { + + displayLoggedInUser () { + const user = this.props.data.users_UserByAuthId + const { classes, match } = this.props + + if (user) { + let displayName = 'No Display Name' + + if ( + user.alias !== null && + user.alias !== '' + ) { displayName = user.alias } + + if ( + user.firstName !== null && + user.firstName !== '' + ) { displayName = user.firstName } + + if ( + user.firstName !== null && + user.firstName !== '' && + user.lastName !== null && + user.lastName !== '' + ) { displayName = user.firstName + ' ' + user.lastName } + + let authArray = this.props.authId.split('|') + let identityProvider = authArray[0] + + return ( +
+ +
+ ) + } else { + return ( +
+ ) + } + } + + componentDidMount () { + + } + + render () { + if (this.loggedInUserStored !== true) { + let user = this.props.data.users_UserByAuthId + + if (user !== undefined) { + localStorage.setItem('loggedInUser', JSON.stringify(this.props.data.users_UserByAuthId)) + this.loggedInUserStored = true + } + } + + return ( +
+ {this.displayLoggedInUser()} +
+ ) + } +} + +export default compose( + graphql(getUserByAuthIdQuery, { // What follows is the way to pass a parameter to a query. + options: (props) => { + return { + variables: { + authId: props.authId + } + } + } + }), + withStyles(styles) +)(LoggedInUser) diff --git a/client/components/NavBar.js b/client/components/NavBar.js new file mode 100644 index 000000000..09d4edf3b --- /dev/null +++ b/client/components/NavBar.js @@ -0,0 +1,151 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import { withStyles } from '@material-ui/core/styles' +import classNames from 'classnames' +import AppBar from '@material-ui/core/AppBar' +import Toolbar from '@material-ui/core/Toolbar' +import Typography from '@material-ui/core/Typography' +import Button from '@material-ui/core/Button' + +// icons +import UsersIcon from '@material-ui/icons/People' +import BrowseIcon from '@material-ui/icons/ImportContacts' +import SearchIcon from '@material-ui/icons/Search' +import ContactIcon from '@material-ui/icons/ContactMail' +import AboutIcon from '@material-ui/icons/FormatShapes' + +import { Link } from 'react-router-dom' + +// components +import LoggedInUser from './LoggedInUser' + +const HomeLink = props => +const BrowseLink = props => +const SearchLink = props => +const AboutLink = props => + +const styles = theme => ({ + root: { + flexGrow: 1 + }, + flex: { + flexGrow: 1, + marginLeft: 30 + }, + menuButton: { + marginLeft: -12, + marginRight: 20 + }, + cssRoot: { + color: '#FFFFFF', + backgroundColor: theme.palette.secondary, + '&:hover': { + backgroundColor: theme.palette.dark + }, + whiteSpace: 'nowrap', + paddingRight: 2 * theme.spacing.unit, + paddingLeft: 2 * theme.spacing.unit + }, + button: { + margin: theme.spacing.unit + }, + leftIcon: { + marginRight: theme.spacing.unit + }, + rightIcon: { + marginLeft: theme.spacing.unit + }, + iconSmall: { + fontSize: 20 + } +}) + +class NavBar extends Component { + + constructor (props) { + super(props) + this.state = { + authId: null + } + } + + componentDidMount () { + let user = localStorage.getItem('user') + let authId + + if (user !== null && user !== undefined && user !== 'undefined') { + user = JSON.parse(user) + authId = user.authId + } + + if (authId !== null && authId !== undefined && authId !== 'undefined') { + this.setState({ authId: authId }) + } + } + + render () { + const { classes, user, match } = this.props + console.log('NavBar: ', user, match) + return ( +
+ + + + Users Module + + + + + + + + +
+ ) + } +} + +NavBar.propTypes = { + classes: PropTypes.object.isRequired, + user: PropTypes.object, + match: PropTypes.object +} + +export default withStyles(styles)(NavBar) + diff --git a/client/components/ProfileImages.js b/client/components/ProfileImages.js new file mode 100644 index 000000000..268efeaee --- /dev/null +++ b/client/components/ProfileImages.js @@ -0,0 +1,52 @@ +import React from 'react' +import Button from '@material-ui/core/Button' +import Dialog from '@material-ui/core/Dialog' +import DialogActions from '@material-ui/core/DialogActions' +import DialogContent from '@material-ui/core/DialogContent' +import DialogContentText from '@material-ui/core/DialogContentText' +import DialogTitle from '@material-ui/core/DialogTitle' +import CssBaseline from '@material-ui/core/CssBaseline' + +class Contact extends React.Component { + state = { + open: true + } + + handleClickOpen = () => { + this.setState({ open: true }) + } + + handleClose = () => { + this.setState({ open: false }) + } + + render () { + return ( + + + + + + {"Section under development."} + + + + The functionality of this section has not been developed yet. We expect to have it for November 2018. Thanks for your understanding. + + + + + + + + ) + } +} + +export default Contact diff --git a/client/components/ProfileSheet.js b/client/components/ProfileSheet.js new file mode 100644 index 000000000..56a4dd74e --- /dev/null +++ b/client/components/ProfileSheet.js @@ -0,0 +1,498 @@ +import React, { Component } from 'react' +import {graphql, compose} from 'react-apollo' +import {getRolesQuery, updateUserMutation, getUsersQuery} from '../queries/queries' + +// Material-ui + +import { withStyles } from '@material-ui/core/styles' +import MenuItem from '@material-ui/core/MenuItem' +import TextField from '@material-ui/core/TextField' +import FormControl from '@material-ui/core/FormControl' +import InputLabel from '@material-ui/core/InputLabel' +import Input from '@material-ui/core/Input' +import Button from '@material-ui/core/Button' +import FormControlLabel from '@material-ui/core/FormControlLabel' +import Checkbox from '@material-ui/core/Checkbox' +import FormGroup from '@material-ui/core/FormGroup' +import Select from '@material-ui/core/Select' +import FormHelperText from '@material-ui/core/FormHelperText' +import Paper from '@material-ui/core/Paper' +import Grid from '@material-ui/core/Grid' +import Typography from '@material-ui/core/Typography' + +// Images +import GithubLogo from '../img/github-logo.png' +import Auth0Logo from '../img/auth0-logo.png' +import AALogo from '../img/aa-logo.png' + +const styles = theme => ({ + root: { + width: '50%', + flexGrow: 1, + padding: 10, + marginLeft: '25%', + marginTop: '2%' + }, + inputField: { + width: '80%', + marginLeft: '10%', + marginTop: 25 + }, + typography: { + width: '80%', + marginLeft: '10%', + marginTop: 40 + }, + checkbox: { + width: 150, + marginLeft: '0%', + marginTop: 20 + }, + selectEmpty: { + marginTop: theme.spacing.unit * 2 + }, + button: { + margin: theme.spacing.unit, + marginTop: theme.spacing.unit * 3 + }, + img: { + display: 'block', + marginTop: 20, + maxWidth: 120, + maxHeight: 24 + } +}) + +class ProfileSheet extends Component { + + constructor (props) { + super(props) + + this.defaultValuesSet = false + + this.state = { + id: '', + firstName: '', + middleName: '', + lastName: '', + bio: '', + email: '', + emailVerified: 0, + isDeveloper: 0, + isTrader: 0, + isDataAnalyst: 0, + roleId: '1', + firstNameError: false, + middleNameError: false, + lastNameError: false, + bioError: false + } + } + + displayRoles () { + var data = this.props.getRolesQuery // When there is more than one query binded to a single componente 'data' is replaced by thename of the query given below at the binding operation. + if (data.loading) { + return ( + Loading roles + ) + } else { + return data.users_Roles.map(role => { + return ( + { role.name } + ) + }) + } + } + + submitForm (e) { + e.preventDefault() + this.props.updateUserMutation({ + variables: { + id: this.state.id, + firstName: this.state.firstName, + middleName: this.state.middleName, + lastName: this.state.lastName, + bio: this.state.bio, + isDeveloper: this.state.isDeveloper, + isTrader: this.state.isTrader, + isDataAnalyst: this.state.isDataAnalyst, + roleId: this.state.roleId + }, + refetchQueries: [{ query: getUsersQuery}] // This allow us to re run whatever queries are necesary after the mutation. + }) + + /* Before we are done, we need to update the state of the local storage. */ + + let user = JSON.parse(localStorage.getItem('loggedInUser')) + + user.firstName = this.state.firstName + user.middleName = this.state.middleName + user.lastName = this.state.lastName + user.bio = this.state.bio + user.isDeveloper = this.state.isDeveloper + user.isTrader = this.state.isTrader + user.isDataAnalyst = this.state.isDataAnalyst + user.role.id = this.state.roleId + + localStorage.setItem('loggedInUser', JSON.stringify(user)) + } + + handleCheckBoxes (e) { + let fieldValue + if (e.target.checked === true) { + fieldValue = 1 + } else { + fieldValue = 0 + + /* When the user unchecks one of the checkboxes, we need to make sure that that Role is not the one selected at the SELECT, + and if it is, then we need to automatically select another one */ + + switch (e.target.id) { + case 'isDeveloper': + if (this.state.roleId === '2') { + this.setState({ roleId: '1'}) + } + break + + case 'isTrader': + if (this.state.roleId === '3') { + this.setState({ roleId: '1'}) + } + break + + case 'isDataAnalyst': + if (this.state.roleId === '4') { + this.setState({ roleId: '1'}) + } + break + default: + } + } + this.setState({ [e.target.id]: fieldValue}) + } + + handleSelect (e) { + /* + Whenever the select component changes its value, we need to activate the type of role selected. + To do so, we change the state of the corresponding type of role here. + */ + + switch (e.target.value) { + case '2': + this.setState({ isDeveloper: 1}) + break + case '3': + this.setState({ isTrader: 1}) + break + case '4': + this.setState({ isDataAnalyst: 1}) + break + default: + } + + this.setState({ roleId: e.target.value }) + } + + handleTextField (e) { + /* + We will do some basic input validations here. If something is wrong we will turn on the error sign on the textfield. + */ + + let value = e.target.value + + switch (e.target.id) { + case 'firstName': + if (value.length > 30) { + this.setState({firstNameError: true}) + } else { + this.setState({firstNameError: false, firstName: value}) + } + break + case 'middleName': + if (value.length > 30) { + this.setState({middleNameError: true}) + } else { + this.setState({middleNameError: false, middleName: value}) + } + break + case 'lastName': + if (value.length > 50) { + this.setState({lastNameError: true}) + } else { + this.setState({lastNameError: false, lastName: value}) + } + break + case 'bio': + if (value.length > 250) { + this.setState({bioError: true}) + } else { + this.setState({bioError: false, bio: value}) + } + break + default: + } + } + + rightCheckboxValue (stateValue) { + if (stateValue === 1) { + return true + } else { return false } + } + + componentWillMount () { + if (this.defaultValuesSet === false) { + let authId = localStorage.getItem('authId') + let userData = localStorage.getItem('loggedInUser') + + if (userData === 'undefined' || userData === null) { return } + + let user = JSON.parse(userData) + this.defaultValuesSet = true + + /* To avoid console warning, we need to take care of the fields that are null. */ + + if (user.firstName === null) { user.firstName = '' } + if (user.middleName === null) { user.middleName = '' } + if (user.lastName === null) { user.lastName = '' } + if (user.bio === null) { user.bio = '' } + + /* Now we are ready to set the initial state. */ + + this.setState({ + id: user.id, + alias: user.alias, + email: user.email, + emailVerified: user.emailVerified, + firstName: user.firstName, + middleName: user.middleName, + lastName: user.lastName, + bio: user.bio, + isDeveloper: user.isDeveloper, + isTrader: user.isTrader, + isDataAnalyst: user.isDataAnalyst, + roleId: user.role.id, + authId: authId + }) + } + } + + displayIdentityProvider () { + const { classes } = this.props + let authId = this.state.authId + + if (authId !== undefined && authId !== null) { + let authArray = this.state.authId.split('|') + let identityProvider = authArray[0] + + switch (identityProvider) { + case 'github': + return ( + Github + ) + break + case 'auth0': + return ( + Auth0 + ) + break + default: + + } + } + } + + render () { + const { classes } = this.props + return ( + + + Profile Sheet + +
+ + + Use this form to control the information you keep at the Advanced Algos system about yourself. + + + + + {this.displayIdentityProvider()} + + + + + This is your basic information we have gotten from the identity provider you used to sign up. This information can not be changed. + + + + + + + + } + label='Email Verified' + /> + + + + Advanced Algos + + + + + Complete your profile with the following optional information. Providing your real name might help other users trust you more. + + + + + + + + + + If you wish, you can add a short paragraph with your Bio or anything you would like to communicate to whoever finds your user profile. + + + + + + Check the following options to enable specialized tools designed for each role. You can allways come back and change these settings later. + + + + + + + } + label='Developer' + /> + + + + } + label='Trader' + /> + + + + } + label='Data Analyst' + /> + + + + +

Your current role determines how the system is going to optimize its user interface to best serves your current needs.

+ + + + Current Role + + + Select from the list your current role + + + + + + + + +
+ + ) + } +} + +export default compose( + graphql(getRolesQuery, {name: 'getRolesQuery'}), + graphql(updateUserMutation, {name: 'updateUserMutation'}), + withStyles(styles) +)(ProfileSheet) // This technique binds more than one query to a single component. diff --git a/client/components/Search.js b/client/components/Search.js new file mode 100644 index 000000000..c62f79384 --- /dev/null +++ b/client/components/Search.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react' +import UserSearch from './UserSearch' +import {compose} from 'react-apollo' +import CssBaseline from '@material-ui/core/CssBaseline' + +// Materia UI + +import { withStyles } from '@material-ui/core/styles' + +const styles = theme => ({ + root: { + flexGrow: 1, + padding: 60, + margin: 2 + } +}) + +class Search extends Component { + + constructor (props) { + super(props) + this.state = { + } + } + render () { + return ( + + + + + ) + } +} + +export default compose( + withStyles(styles) +)(Search) diff --git a/client/components/User.js b/client/components/User.js new file mode 100644 index 000000000..043f3ddaf --- /dev/null +++ b/client/components/User.js @@ -0,0 +1,14 @@ +import React from 'react' +import UserTabs from './UserTabs' +import CssBaseline from '@material-ui/core/CssBaseline' + +const User = () => { + return ( + + + + + ) +} + +export default User diff --git a/client/components/UserList.js b/client/components/UserList.js new file mode 100644 index 000000000..4e5751836 --- /dev/null +++ b/client/components/UserList.js @@ -0,0 +1,185 @@ +import React, { Component } from 'react'; +import {graphql, compose} from 'react-apollo'; +import {getUsersQuery} from '../queries/queries'; + +// Materia UI + +import { withStyles } from '@material-ui/core/styles'; +import Card from '@material-ui/core/Card'; +import CardActionArea from '@material-ui/core/CardActionArea'; +import CardActions from '@material-ui/core/CardActions'; +import CardContent from '@material-ui/core/CardContent'; +import CardMedia from '@material-ui/core/CardMedia'; +import Button from '@material-ui/core/Button'; +import Typography from '@material-ui/core/Typography'; +import Grid from '@material-ui/core/Grid'; +import Paper from '@material-ui/core/Paper'; + +// Full screen dialog imports (still Material UI) + +import PropTypes from 'prop-types'; +import Dialog from '@material-ui/core/Dialog'; +import AppBar from '@material-ui/core/AppBar'; +import Toolbar from '@material-ui/core/Toolbar'; +import IconButton from '@material-ui/core/IconButton'; + +import CloseIcon from '@material-ui/icons/Close'; +import Slide from '@material-ui/core/Slide'; + +// components +import UserProfile from './UserProfile'; + +// Images +import PortraitImage from '../img/portrait.jpg' + +const styles = theme => ({ + root: { + flexGrow: 1, + padding: 60, + margin: 2, + }, + card: { + maxWidth: 345, + minWidth: 300, + paddingTop:'30' + }, + media: { + height: 0, + paddingTop: '56.25%', // 16:9, + marginTop:'30', + minWidth: 300 + }, + typography: { + maxWidth: 345, + minWidth: 300, + paddingTop:'30' + }, + appBar: { + position: 'relative', + }, + flex: { + flex: 1, + }, + grid: { + paddingTop: 30, + marginTop:'30' + }, +}); + +function Transition(props) { + return ; +} + +class UserList extends Component { + + constructor(props){ + super(props); + this.state = { + selected: null, + open: false + } + } + + handleClickOpen = () => { + this.setState({ open: true }); + }; + + handleClose = () => { + this.setState({ open: false }); + }; + + displayUsers(){ + + let data = this.props.getUsersQuery; + const { classes } = this.props; + + if(data.loading){ + return (
Loading Users...
); + } else { + return data.users_Users.map(user => { + + return ( + + + { + this.setState({ selected: user.id}); + } + }> + + + + + {user.alias} + + + {user.bio} + + + + + + + + + + + + + + + User Profile + + + + + + + + + + + + + + + + + ) + }); + } + } + + render() { + const { classes } = this.props; + return ( + + + {this.displayUsers()} + + + ); + } +} + +UserList.propTypes = { + classes: PropTypes.object.isRequired, +}; + +export default compose( + graphql(getUsersQuery, {name: "getUsersQuery"}), + withStyles(styles) +) (UserList); // This technique binds more than one query to a single component. diff --git a/client/components/UserProfile.js b/client/components/UserProfile.js new file mode 100644 index 000000000..21906da18 --- /dev/null +++ b/client/components/UserProfile.js @@ -0,0 +1,112 @@ +import React, { Component } from 'react' +import {graphql, compose} from 'react-apollo' +import {getUserProfileQuery} from '../queries/queries' + +// Materia UI + +import { withStyles } from '@material-ui/core/styles' +import Grid from '@material-ui/core/Grid' +import Card from '@material-ui/core/Card' +import CardActionArea from '@material-ui/core/CardActionArea' +import CardContent from '@material-ui/core/CardContent' +import CardMedia from '@material-ui/core/CardMedia' +import Typography from '@material-ui/core/Typography' +import Divider from '@material-ui/core/Divider' + +// Images +import PortraitImage from '../img/portrait.jpg' + +const styles = theme => ({ + root: { + flexGrow: 1, + padding: 60, + margin: 2 + }, + card: { + width: '80%', + paddingTop: '30' + }, + media: { + height: 0, + paddingTop: '56.25%', // 16:9, + marginTop: '30', + minWidth: '80%' + }, + grid: { + paddingTop: '30', + marginTop: '30' + }, + typography: { + width: '100%', + marginTop: 20, + marginBottom: 20 + } + +}) + +class UserProfile extends Component { + + displayUserProfile () { + const user = this.props.data.users_User + const { classes } = this.props + + if (user) { + return ( + + + { + this.setState({ selected: user.id}) + } + }> + + + + + { user.firstName } { user.lastName } ( {user.alias} ) + + + + + { user.role.name } + + + + + { user.bio } + + + + + + ) + } else { + return (
No User selected...
) + } + } + + render () { + return ( + + {this.displayUserProfile()} + + ) + } +} + +export default compose( + graphql(getUserProfileQuery, { // What follows is the way to pass a parameter to a query. + options: (props) => { + return { + variables: { + name: 'getUserProfileQuery', + id: props.userId + } + } + }}), + withStyles(styles) +)(UserProfile) // This technique binds more than one query to a single component. diff --git a/client/components/UserSearch.js b/client/components/UserSearch.js new file mode 100644 index 000000000..6f184df2e --- /dev/null +++ b/client/components/UserSearch.js @@ -0,0 +1,267 @@ +import React, { Component } from 'react' +import {graphql, compose} from 'react-apollo' +import {getUsersBySearchFields} from '../queries/queries' + +// Materia UI + +import { withStyles } from '@material-ui/core/styles' +import Card from '@material-ui/core/Card' +import CardActionArea from '@material-ui/core/CardActionArea' +import CardActions from '@material-ui/core/CardActions' +import CardContent from '@material-ui/core/CardContent' +import CardMedia from '@material-ui/core/CardMedia' +import Button from '@material-ui/core/Button' +import Typography from '@material-ui/core/Typography' +import Grid from '@material-ui/core/Grid' + +import TextField from '@material-ui/core/TextField' + +// Images +import PortraitImage from '../img/portrait.jpg' + +const styles = theme => ({ + card: { + maxWidth: 150, + minWidth: 150, + paddingTop: '30', + marginBottom: 40 + }, + media: { + height: 0, + paddingTop: '56.25%', // 16:9, + marginTop: '30', + minWidth: 300 + }, + typography: { + maxWidth: 345, + minWidth: 300, + paddingTop: '30' + }, + appBar: { + position: 'relative' + }, + flex: { + flex: 1 + }, + grid: { + paddingTop: '30', + marginTop: 30 + }, + inputField: { + width: '80%', + marginLeft: '10%', + marginTop: 25 + }, + formTypography: { + width: '80%', + marginLeft: '10%', + marginTop: 40 + }, + button: { + margin: theme.spacing.unit, + marginTop: theme.spacing.unit * 3 + } +}) + +class UserSearch extends Component { + + constructor (props) { + super(props) + + this.state = { + alias: '', + firstName: '', + middleName: '', + lastName: '' + } + } + + submitForm (e) { + e.preventDefault() + + this.props.getUsersBySearchFields.variables.alias = this.state.alias + this.props.getUsersBySearchFields.variables.firstName = this.state.firstName + this.props.getUsersBySearchFields.variables.middleName = this.state.middleName + this.props.getUsersBySearchFields.variables.lastName = this.state.lastName + + this.props.getUsersBySearchFields.refetch({}) + } + + handleTextField (e) { + /* + We will do some basic input validations here. If something is wrong we will turn on the error sign on the textfield. + */ + + let value = e.target.value + + switch (e.target.id) { + case 'alias': + if (value.length > 30) { + this.setState({aliasError: true}) + } else { + this.setState({aliasError: false, alias: value}) + } + break + case 'firstName': + if (value.length > 30) { + this.setState({firstNameError: true}) + } else { + this.setState({firstNameError: false, firstName: value}) + } + break + case 'middleName': + if (value.length > 30) { + this.setState({middleNameError: true}) + } else { + this.setState({middleNameError: false, middleName: value}) + } + break + case 'lastName': + if (value.length > 50) { + this.setState({lastNameError: true}) + } else { + this.setState({lastNameError: false, lastName: value}) + } + break + default: + } + } + + selectText () { + if (this.props.selectButton === true) { + return ({this.props.selectText}) + } else { + return () + } + } + + selectButton (user) { + if (this.props.selectButton === true) { + return ( + + ) + } else { + return (
) + } + } + + displayUsers () { + let data = this.props.getUsersBySearchFields + const { classes } = this.props + + if (data.loading) { + return (
Loading Users...
) + } else { + if (data.users_UsersSearch === undefined) { + return (
No Users to Display
) + } else { + return data.users_UsersSearch.map(user => { + return ( + + + { + this.setState({ selected: user.id}) + } + }> + + + + + {user.alias} + + + + + + + {this.selectButton(user)} + + + + + + + ) + }) + } + } + } + + render () { + const { classes } = this.props + return ( +
+
+ + + Use any of these fileds to search for users. {this.selectText()} + + + + + + + + + + + + + + + + + + + {this.displayUsers()} + +
+ ) + } +} + +export default compose( + graphql(getUsersBySearchFields, {name: 'getUsersBySearchFields'}), + withStyles(styles) +)(UserSearch) // This technique binds more than one query to a single component. diff --git a/client/components/UserTabs.js b/client/components/UserTabs.js new file mode 100644 index 000000000..28b3ae94c --- /dev/null +++ b/client/components/UserTabs.js @@ -0,0 +1,85 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +import AppBar from '@material-ui/core/AppBar'; +import Tabs from '@material-ui/core/Tabs'; +import Tab from '@material-ui/core/Tab'; +import ProfileSheetIcon from '@material-ui/icons/Create'; +import ProfileImagesIcon from '@material-ui/icons/Wallpaper'; +import YourReferrerIcon from '@material-ui/icons/AccessibilityNew'; +import DescendentsIcon from '@material-ui/icons/DeviceHub'; +import Typography from '@material-ui/core/Typography'; + +// Components + +import ProfileSheet from './ProfileSheet'; +import ProfileImages from './ProfileImages'; +import YourReferrer from './YourReferrer'; +import YourDescendents from './YourDescendents'; + +function TabContainer(props) { + return ( + + {props.children} + + ); +} + +TabContainer.propTypes = { + children: PropTypes.node.isRequired, +}; + +const styles = theme => ({ + root: { + flexGrow: 1, + width: '100%', + backgroundColor: theme.palette.background.paper, + padding: 0, + margin: 0, + }, +}); + +class UserTabs extends React.Component { + state = { + value: 0 + }; + + handleChange = (event, value) => { + this.setState({ value }); + }; + + render() { + const { classes } = this.props; + const { value } = this.state; + + return ( +
+ + + } /> + } /> + } /> + } /> + + + {value === 0 && } + {value === 1 && } + {value === 2 && } + {value === 3 && } +
+ ); + } +} + +UserTabs.propTypes = { + classes: PropTypes.object.isRequired, +}; + +export default withStyles(styles)(UserTabs); diff --git a/client/components/YourDescendents.js b/client/components/YourDescendents.js new file mode 100644 index 000000000..dd5f4aec4 --- /dev/null +++ b/client/components/YourDescendents.js @@ -0,0 +1,86 @@ +import React, { Component } from 'react' +import {compose} from 'react-apollo' + +// Materia UI + +import { withStyles } from '@material-ui/core/styles' +import Typography from '@material-ui/core/Typography' +import Grid from '@material-ui/core/Grid' +import Paper from '@material-ui/core/Paper' + +// components +import DescendentsTree from './DescendentsTree' + +const styles = theme => ({ + root: { + width: '50%', + flexGrow: 1, + padding: 10, + marginLeft: '25%', + marginTop: '2%' + }, + typography: { + width: '80%', + marginLeft: '10%', + marginTop: 40, + marginBottom: 40 + }, + grid: { + paddingTop: '30', + marginTop: 30 + } +}) + +class YourDescendents extends Component { + + constructor (props) { + super(props) + + this.defaultValuesSet = false + + this.state = { + id: '' + } + } + + componentWillMount () { + if (this.defaultValuesSet === false) { + let userData = localStorage.getItem('loggedInUser') + + if (userData === 'undefined') { return } + + let user = JSON.parse(userData) + this.defaultValuesSet = true + + /* Now we are ready to set the initial state. */ + this.setState({ + id: user.id + }) + } + } + + render () { + const { classes } = this.props + + return ( + + + Your Descendents + + + + These are your decendents within the project. Your children referred you as the one who brought them to the project, while + your grandchildren referred your children and so on. In order to be able to see your descendents, the users who you referred + must first point to you as your referrer. + + + + + + ) + } +} + +export default compose( + withStyles(styles) +)(YourDescendents) // This technique binds more than one query to a single component. diff --git a/client/components/YourReferrer.js b/client/components/YourReferrer.js new file mode 100644 index 000000000..946f2e4e7 --- /dev/null +++ b/client/components/YourReferrer.js @@ -0,0 +1,146 @@ +import React, { Component } from 'react' +import {graphql, compose} from 'react-apollo' +import {updateReferrerMutation} from '../queries/queries' + +// components + +import UserSearch from './UserSearch' +import UserProfile from './UserProfile' + +// Material-ui + +import { withStyles } from '@material-ui/core/styles' +import Paper from '@material-ui/core/Paper' +import Typography from '@material-ui/core/Typography' + +const styles = theme => ({ + root: { + width: '50%', + flexGrow: 1, + padding: 10, + marginLeft: '25%', + marginTop: '2%' + }, + typography: { + width: '80%', + marginLeft: '10%', + marginTop: 40, + marginBottom: 40 + }, + button: { + margin: theme.spacing.unit, + marginTop: theme.spacing.unit * 3 + }, + inputField: { + width: '80%', + marginLeft: '10%', + marginTop: 25 + } +}) + +class YourReferrer extends Component { + + constructor (props) { + super(props) + + this.defaultValuesSet = false + + this.state = { + id: '', + referrerId: '', + firstNameError: false, + middleNameError: false, + lastNameError: false, + aliasError: false + } + } + + userSelected (referrerUser) { + this.setState({referrerId: referrerUser.id}) + + this.props.updateReferrerMutation({ + variables: { + id: this.state.id, + referrerId: referrerUser.id + } + }) + + /* Before we are done, we need to update the state of the local storage. */ + + let user = JSON.parse(localStorage.getItem('loggedInUser')) + + user.referrerId = referrerUser.id + + localStorage.setItem('loggedInUser', JSON.stringify(user)) + } + + renderMode () { + const { classes } = this.props + + if (this.state.referrerId !== null) { + return ( +
+ + This is the user who introduced you to the project. + + + + + + This information can not be changed. + +
+ ) + } else { + return ( +
+ + We know that a group often becomes more intelligent when the number of people in the group increases. + To incentivize members of the community to invite more people to join we have developed this referral + program in which you can specify who referred you to the project, and see the members who pointed at + you as their referrer. Later this information will be available at your user profile and add to your + overall reputation within the project. + + + +
+ ) + } + } + + componentWillMount () { + if (this.defaultValuesSet === false) { + let userData = localStorage.getItem('loggedInUser') + + if (userData === 'undefined') { return } + + let user = JSON.parse(userData) + this.defaultValuesSet = true + + /* Now we are ready to set the initial state. */ + + this.setState({ + id: user.id, + referrerId: user.referrerId + }) + } + } + + render () { + const { classes } = this.props + return ( + + + Your Referrer + + + {this.renderMode()} + + ) + } +} + +export default compose( + graphql(updateReferrerMutation, {name: 'updateReferrerMutation'}), + withStyles(styles) +)(YourReferrer) // This technique binds more than one query to a single component. diff --git a/client/img/aa-logo-dark-8.png b/client/img/aa-logo-dark-8.png new file mode 100644 index 000000000..a6bcfcb90 Binary files /dev/null and b/client/img/aa-logo-dark-8.png differ diff --git a/client/img/aa-logo.png b/client/img/aa-logo.png new file mode 100644 index 000000000..9701ee1c0 Binary files /dev/null and b/client/img/aa-logo.png differ diff --git a/client/img/auth0-logo.png b/client/img/auth0-logo.png new file mode 100644 index 000000000..ba4c72724 Binary files /dev/null and b/client/img/auth0-logo.png differ diff --git a/client/img/email.png b/client/img/email.png new file mode 100644 index 000000000..93b2edf0c Binary files /dev/null and b/client/img/email.png differ diff --git a/client/img/github-head-negative.png b/client/img/github-head-negative.png new file mode 100644 index 000000000..1a1d757b1 Binary files /dev/null and b/client/img/github-head-negative.png differ diff --git a/client/img/github-head.png b/client/img/github-head.png new file mode 100644 index 000000000..a815207a3 Binary files /dev/null and b/client/img/github-head.png differ diff --git a/client/img/github-logo.png b/client/img/github-logo.png new file mode 100644 index 000000000..336861716 Binary files /dev/null and b/client/img/github-logo.png differ diff --git a/client/img/github-negative.png b/client/img/github-negative.png new file mode 100644 index 000000000..967efa057 Binary files /dev/null and b/client/img/github-negative.png differ diff --git a/client/img/github.png b/client/img/github.png new file mode 100644 index 000000000..92d3c954b Binary files /dev/null and b/client/img/github.png differ diff --git a/client/img/portrait.jpg b/client/img/portrait.jpg new file mode 100644 index 000000000..2108ceee8 Binary files /dev/null and b/client/img/portrait.jpg differ diff --git a/client/index.js b/client/index.js new file mode 100644 index 000000000..e77b9c49f --- /dev/null +++ b/client/index.js @@ -0,0 +1,86 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import { Route, BrowserRouter, Switch } from 'react-router-dom' +import { hot } from 'react-hot-loader' + +import { withStyles } from '@material-ui/core/styles' + +// Components +import NavBar from './components/NavBar' +import Home from './components/Home' +import User from './components/User' +import Browse from './components/Browse' +import Search from './components/Search' +import About from './components/About' +import Contact from './components/Contact' + +import { getItem } from './utils/local-storage' +import { + globalStyles +} from './theme' + +class App extends Component { + constructor (props) { + super(props) + this.state = { + user: null + } + } + + async componentDidMount () { + let user = await getItem('user') + + if (user !== null && user !== undefined && user !== 'undefined') { + user = JSON.parse(user) + this.setState({ user: user }) + } + } + + render () { + const { match } = this.props + + return ( + +
+ + + + } + /> + } + /> + } + /> + } + /> + } + /> + + +
+
+ ) + } +} + +App.propTypes = { + auth: PropTypes.object +} + +const StyledApp = withStyles(globalStyles)(App) +export default hot(module)(StyledApp) diff --git a/client/package.json b/client/package.json index 49b3350eb..3a3870b15 100644 --- a/client/package.json +++ b/client/package.json @@ -1,7 +1,7 @@ { "name": "@advancedalgos/users-client", "description": "Advanced Algos Users client-side web app", - "version": "0.0.11", + "version": "0.0.12", "main": "src/index.js", "dependencies": { "@material-ui/core": "^3.2.0", diff --git a/client/queries/queries.js b/client/queries/queries.js new file mode 100644 index 000000000..841538779 --- /dev/null +++ b/client/queries/queries.js @@ -0,0 +1,187 @@ +import gql from 'graphql-tag' + +const getUsersQuery = gql` +{ + users_Users { + id + alias + firstName + middleName + lastName + bio + role { + id + name + } + } +} +` +const getUserProfileQuery = gql` +query($id: ID){ + users_User (id: $id){ + id + alias + firstName + middleName + lastName + bio + avatarHandle + role { + id + name + } + } +} +` +const getUserByAuthIdQuery = gql` +query($authId: String){ + users_UserByAuthId (authId: $authId){ + id + referrerId + alias + firstName + middleName + lastName + bio + email + emailVerified + isDeveloper + isDataAnalyst + isTrader + avatarHandle + avatarChangeDate + role { + id + } + } +} +` +const getUsersBySearchFields = gql` +query( + $alias: String, + $firstName: String, + $middleName: String, + $lastName: String +){ + users_UsersSearch (alias: $alias, firstName: $firstName, middleName: $middleName, lastName: $lastName){ + id + alias + firstName + middleName + lastName + } +} +` +const getDescendentsQuery = gql` +query( + $id: String +){ + users_Descendents (id: $id){ + id + alias + firstName + middleName + lastName + referrerId + descendents { + id + alias + firstName + middleName + lastName + referrerId + descendents { + id + alias + firstName + middleName + lastName + referrerId + } + } + } +} +` +const getRolesQuery = gql` +{ + users_Roles { + id + name + } +} +` +const updateUserMutation = gql` +mutation( + $id: ID!, + $firstName:String, + $middleName:String, + $lastName:String, + $bio:String, + $isDeveloper:Int, + $isTrader:Int, + $isDataAnalyst:Int, + $roleId:String! +) + { + users_UpdateUser ( + id: $id, + firstName:$firstName, + middleName: $middleName, + lastName: $lastName, + bio: $bio, + isDeveloper: $isDeveloper, + isTrader: $isTrader, + isDataAnalyst: $isDataAnalyst, + roleId: $roleId + ) + { + id + alias + } +} +` +const updateReferrerMutation = gql` +mutation( + $id: ID!, + $referrerId:String! +) + { + users_UpdateUserReferrer ( + id: $id, + referrerId:$referrerId + ) + { + id + referrerId + } +} +` +const updateUserImagesMutation = gql` +mutation( + $id: ID!, + $avatarHandle:String, + $avatarChangeDate:String +) + { + users_UpdateUserImages ( + id: $id, + avatarHandle:$avatarHandle, + avatarChangeDate: $avatarChangeDate + ) + { + id + alias + } +} +` +export { + getUsersQuery, + getUserByAuthIdQuery, + getRolesQuery, + getUserProfileQuery, + getUsersBySearchFields, + getDescendentsQuery, + updateUserMutation, + updateReferrerMutation, + updateUserImagesMutation +} diff --git a/client/src/components/Home.js b/client/src/components/Home.js index 03c650e47..bb829f8dd 100644 --- a/client/src/components/Home.js +++ b/client/src/components/Home.js @@ -64,7 +64,7 @@ class Home extends Component { color='textSecondary' component='h3' > - Welcome to Advanced Algos Users Module This is the Source Version 2 + Welcome to Advanced Algos Users Module
@@ -81,7 +81,7 @@ class Home extends Component { Development Status - This module is is currently under heavy development. Implementation started 1st of September 2018 and this is the result of the 2nd sprint of 2 weeks of work each. + This module is is currently under development. Implementation started 1st of September 2018 and this is the result of the 3rd sprint of 2 weeks of work each. What can you do? diff --git a/client/src/components/LoggedInUser.js b/client/src/components/LoggedInUser.js index 1d9fbad7e..933394e43 100644 --- a/client/src/components/LoggedInUser.js +++ b/client/src/components/LoggedInUser.js @@ -1,6 +1,8 @@ import React, { Component } from 'react' -import {graphql} from 'react-apollo' +import {graphql, compose} from 'react-apollo' import {getUserByAuthIdQuery} from '../queries/queries' +import { withStyles } from '@material-ui/core/styles' +import classNames from 'classnames' import Button from '@material-ui/core/Button' import IconButton from '@material-ui/core/IconButton' @@ -11,10 +13,47 @@ import { Link } from 'react-router-dom' const UserLink = props => +const styles = theme => ({ + root: { + flexGrow: 1 + }, + flex: { + flexGrow: 1, + marginLeft: 30 + }, + menuButton: { + marginLeft: -12, + marginRight: 20 + }, + cssRoot: { + color: '#FFFFFF', + backgroundColor: theme.palette.secondary, + '&:hover': { + backgroundColor: theme.palette.dark + }, + whiteSpace: 'nowrap', + paddingRight: 2 * theme.spacing.unit, + paddingLeft: 2 * theme.spacing.unit + }, + button: { + margin: theme.spacing.unit + }, + leftIcon: { + marginRight: theme.spacing.unit + }, + rightIcon: { + marginLeft: theme.spacing.unit + }, + iconSmall: { + fontSize: 20 + } +}) + class LoggedInUser extends Component { displayLoggedInUser () { const user = this.props.data.users_UserByAuthId + const { classes, match } = this.props if (user) { let displayName = 'No Display Name' @@ -41,13 +80,16 @@ class LoggedInUser extends Component { return (
- - - +
) } else { @@ -79,12 +121,15 @@ class LoggedInUser extends Component { } } -export default graphql(getUserByAuthIdQuery, { // What follows is the way to pass a parameter to a query. - options: (props) => { - return { - variables: { - authId: props.authId +export default compose( + graphql(getUserByAuthIdQuery, { // What follows is the way to pass a parameter to a query. + options: (props) => { + return { + variables: { + authId: props.authId + } } } - } -})(LoggedInUser) // This binds the querty to the component + }), + withStyles(styles) +)(LoggedInUser) diff --git a/client/src/components/NavBar.js b/client/src/components/NavBar.js index 643149680..09d4edf3b 100644 --- a/client/src/components/NavBar.js +++ b/client/src/components/NavBar.js @@ -91,7 +91,7 @@ class NavBar extends Component { - Manage Users + Users Module - +
diff --git a/client/theme.js b/client/theme.js new file mode 100644 index 000000000..96492c48c --- /dev/null +++ b/client/theme.js @@ -0,0 +1,65 @@ +import { createMuiTheme } from '@material-ui/core/styles' + +export const theme = createMuiTheme({ + palette: { + primary: { main: '#303036' }, // DARK. + secondary: { main: '#CC5835' } // RUSTED_RED. + }, + typography: { + fontFamily: '"Saira","Saira Condenses", sans-serif' + }, + overrides: { + Paper: { + root: { + backgroundColor: '#ffffff' + }, + elevation: 0, + square: true + } + } +}) + +export const globalStyles = theme => ({ + '@global': { + body: { + backgroundColor: theme.palette.common.white + } + }, + appBar: { + position: 'relative' + }, + toolbarTitle: { + flex: 1 + }, + layout: { + width: 'auto', + marginLeft: theme.spacing.unit * 3, + marginRight: theme.spacing.unit * 3, + [theme.breakpoints.up(900 + theme.spacing.unit * 3 * 2)]: { + width: 900, + marginLeft: 'auto', + marginRight: 'auto' + } + }, + heroContent: { + maxWidth: 600, + margin: '0 auto', + padding: `${theme.spacing.unit * 8}px 0 ${theme.spacing.unit * 6}px` + }, + cardHeader: { + backgroundColor: theme.palette.grey[200] + }, + cardPricing: { + display: 'flex', + justifyContent: 'center', + alignItems: 'baseline', + marginBottom: theme.spacing.unit * 2 + }, + cardActions: { + [theme.breakpoints.up('sm')]: { + paddingBottom: theme.spacing.unit * 2 + } + } +}) + +export default theme diff --git a/client/utils/local-storage.js b/client/utils/local-storage.js new file mode 100644 index 000000000..963ba0f36 --- /dev/null +++ b/client/utils/local-storage.js @@ -0,0 +1,9 @@ +const getItem = async name => window.localStorage.getItem(name) +const setItem = async (name, value) => window.localStorage.setItem(name, value) +const removeItem = async name => window.localStorage.removeItem(name) + +export { + getItem, + setItem, + removeItem +}