From 81a93b92a6ef13dc83d27af01380c165b0a89ce1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 27 Sep 2018 11:56:57 +0200 Subject: [PATCH] Your Referrer Form there --- client/src/components/UserDescendents.js | 169 +++++++++++++++++++++++ client/src/components/UserReferrals.js | 92 ++++++++++-- 2 files changed, 247 insertions(+), 14 deletions(-) create mode 100644 client/src/components/UserDescendents.js diff --git a/client/src/components/UserDescendents.js b/client/src/components/UserDescendents.js new file mode 100644 index 000000000..c2860f0e0 --- /dev/null +++ b/client/src/components/UserDescendents.js @@ -0,0 +1,169 @@ +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' + +// components +import UserProfile from './UserProfile' + +// 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 UserDescendents 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({}) + } + + displayUsers () { + let data = this.props.getUsersBySearchFields + const { classes } = this.props + + if (data.loading) { + return (
Loading Users...
) + } else { + if (data.usersSearch === undefined) { + return (
No Users to Display
) + } else { + return data.usersSearch.map(user => { + return ( + + + { + this.setState({ selected: user.id}) + } + }> + + + + + {user.alias} + + + + + + + {this.selectButton(user)} + + + + + + + ) + }) + } + } + } + + render () { + const { classes } = this.props + return ( +
+
+ + + 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. + + + + + + + +
+ + + {this.displayUsers()} + +
+ ) + } +} + +export default compose( + graphql(getUsersBySearchFields, {name: 'getUsersBySearchFields'}), + withStyles(styles) +)(UserDescendents) // This technique binds more than one query to a single component. diff --git a/client/src/components/UserReferrals.js b/client/src/components/UserReferrals.js index 6e6fb8a1a..8ff4eff24 100644 --- a/client/src/components/UserReferrals.js +++ b/client/src/components/UserReferrals.js @@ -28,11 +28,17 @@ const styles = theme => ({ typography: { width: '80%', marginLeft: '10%', - marginTop: 40 + marginTop: 40, + marginBottom: 40 }, button: { margin: theme.spacing.unit, marginTop: theme.spacing.unit * 3 + }, + inputField: { + width: '80%', + marginLeft: '10%', + marginTop: 25 } }) @@ -74,6 +80,74 @@ class UserReferrals extends Component { localStorage.setItem('loggedInUser', JSON.stringify(user)) } + renderMode () { + const { classes } = this.props + + if (this.state.referrerId !== '') { + 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') @@ -97,21 +171,11 @@ class UserReferrals extends Component { return ( - Referral Program - - - - 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. - - - + Your Referrer + + {this.renderMode()} - ) } }