From 948a0285af72bb2e992b339c361ef640760c7daf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 13 Sep 2018 12:18:35 +0200 Subject: [PATCH] User Profile component converted to Material UI --- client/src/components/UserProfile.js | 103 +++++++++++++++++++-------- 1 file changed, 73 insertions(+), 30 deletions(-) diff --git a/client/src/components/UserProfile.js b/client/src/components/UserProfile.js index 2e701626c..0bcec7d79 100644 --- a/client/src/components/UserProfile.js +++ b/client/src/components/UserProfile.js @@ -1,43 +1,86 @@ -import React, { Component } from 'react'; -import {graphql} from 'react-apollo'; -import {getUserProfileQuery} from '../queries/queries'; +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 Typography from '@material-ui/core/Typography' +import Grid from '@material-ui/core/Grid' +import Paper from '@material-ui/core/Paper' + +const styles = theme => ({ + root: { + flexGrow: 1, + padding: 60, + margin: 2 + }, + card: { + maxWidth: 345, + paddingTop: '30' + }, + media: { + height: 0, + paddingTop: '56.25%', // 16:9, + marginTop: '30' + }, + horizontal: + { + display: 'inline', + margin: theme.spacing.unit + }, + appBar: { + position: 'relative' + }, + flex: { + flex: 1 + }, + grid: { + paddingTop: '30', + marginTop: '30' + } +}) class UserProfile extends Component { - displayUserProfile(){ + displayUserProfile () { + const {user} = this.props.data - const {user} = this.props.data; - - if(user){ - return( -
-

{ user.alias }

-

{ user.firstName }

-

{ user.lastName }

-

{ user.role.name }

-
- ); + if (user) { + return ( +
+

{ user.alias }

+

{ user.firstName }

+

{ user.lastName }

+

{ user.role.name }

+
+ ) } else { - return(
No User selected...
); + return (
No User selected...
) } } - render() { - + render () { + const { classes } = this.props return ( -
- {this.displayUserProfile()} -
- ); + + + {this.displayUserProfile()} + + + ) } } -export default graphql(getUserProfileQuery, { // What follows is the way to pass a parameter to a query. - options: (props) => { - return { - variables: { - id: props.userId +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 + } } - } - } -})(UserProfile); // This binds the querty to the component + }}), + withStyles(styles) +)(UserProfile) // This technique binds more than one query to a single component.