Client: create DashCreateTeamWrapper
This commit is contained in:
1 parent
1637abbc88
commit
f7c5e9cc70
8 files changed
+167
-70
No files matched your search
@@ -3,10 +3,7 @@ import PropTypes from 'prop-types'
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
|
||||
import Grid from '@material-ui/core/Grid'
|
||||
import Card from '@material-ui/core/Card'
|
||||
import CardContent from '@material-ui/core/CardContent'
|
||||
|
||||
import CreateTeam from './components/CreateTeam'
|
||||
import DashTeam from './components/DashTeam'
|
||||
import DashEditor from './components/DashEditor'
|
||||
|
||||
@@ -45,23 +42,13 @@ export class Overview extends Component {
|
||||
const { classes } = this.props
|
||||
return (
|
||||
<Grid container spacing={24}>
|
||||
<Grid container spacing={24}>
|
||||
<Grid item>
|
||||
<Card className={classes.card}>
|
||||
<div className={classes.cardDetails}>
|
||||
<CardContent className={classes.createCardContent}>
|
||||
<CreateTeam classes={classes} />
|
||||
</CardContent>
|
||||
</div>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<DashTeam classes={classes} />
|
||||
<DashEditor classes={classes} />
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Overview.propTypes = {
|
||||
classes: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
|
||||
import Grid from '@material-ui/core/Grid'
|
||||
import Card from '@material-ui/core/Card'
|
||||
import CardContent from '@material-ui/core/CardContent'
|
||||
|
||||
import CreateTeam from './CreateTeam'
|
||||
|
||||
const styles = theme => ({
|
||||
card: {
|
||||
display: 'flex',
|
||||
width: '100%'
|
||||
},
|
||||
cardDetails: {
|
||||
display: 'flex',
|
||||
flex: 1
|
||||
},
|
||||
cardContent: {
|
||||
flex: 1
|
||||
},
|
||||
cardMedia: {
|
||||
flex: 1,
|
||||
width: 160,
|
||||
height: 160,
|
||||
justifyContent: 'flex-start'
|
||||
}
|
||||
})
|
||||
|
||||
const CreateTeamWrapper = ({ classes }) => (
|
||||
<Grid container spacing={24}>
|
||||
<Grid item>
|
||||
<Card className={classes.card}>
|
||||
<div className={classes.cardDetails}>
|
||||
<CardContent className={classes.createCardContent}>
|
||||
<CreateTeam classes={classes} />
|
||||
</CardContent>
|
||||
</div>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
|
||||
CreateTeamWrapper.propTypes = {
|
||||
classes: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
export default withStyles(styles)(CreateTeamWrapper)
|
||||
@@ -5,27 +5,29 @@ import { withStateHandlers, lifecycle, compose } from 'recompose'
|
||||
|
||||
import Typography from '@material-ui/core/Typography'
|
||||
import Grid from '@material-ui/core/Grid'
|
||||
import Card from '@material-ui/core/Card'
|
||||
import CardContent from '@material-ui/core/CardContent'
|
||||
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import DashTeamItem from './DashTeamItem'
|
||||
import CreateTeamWrapper from './CreateTeamWrapper'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import { isDefined, isString } from '../../../utils/js-helpers'
|
||||
import { getItem } from '../../../utils/local-storage'
|
||||
|
||||
export const DashTeam = ({ user = null }) => {
|
||||
console.log('DashTeam 1: ', user)
|
||||
export const DashTeam = ({ classes, user = null }) => {
|
||||
let owner
|
||||
let loader
|
||||
let authId = null
|
||||
if (user !== null && isString(user)) {
|
||||
owner = JSON.parse(user)
|
||||
if (isDefined(owner.sub)) authId = owner.sub
|
||||
if (isDefined(owner.authId)) authId = owner.authId
|
||||
} else {
|
||||
loader = (<Typography variant='caption'>Loading...</Typography>)
|
||||
}
|
||||
|
||||
console.log('DashTeam 2: ', owner, authId)
|
||||
if (authId === null) {
|
||||
return (
|
||||
<Grid item md={6}>
|
||||
@@ -47,21 +49,30 @@ export const DashTeam = ({ user = null }) => {
|
||||
let errors
|
||||
let queryLoader
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => (
|
||||
<Typography key={i} variant='caption'>{message}</Typography>
|
||||
))
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>{displayMessage}</Typography>
|
||||
)
|
||||
})
|
||||
}
|
||||
if (!loading) {
|
||||
return (
|
||||
<Grid container spacing={24}>
|
||||
{!loading && data.teamsByOwner.edges.map(team => (
|
||||
<DashTeamItem key={team.id} />
|
||||
))}
|
||||
{queryLoader}
|
||||
{errors}
|
||||
{loader}
|
||||
</Grid>
|
||||
)
|
||||
if (data.teamsByOwner.edges.length > 0) {
|
||||
return (
|
||||
<Grid container spacing={24}>
|
||||
{!loading && data.teamsByOwner.edges.map(team => (
|
||||
<DashTeamItem key={team.id} />
|
||||
))}
|
||||
{queryLoader}
|
||||
{errors}
|
||||
{loader}
|
||||
</Grid>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<CreateTeamWrapper />
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
<Grid container spacing={24}>
|
||||
@@ -80,7 +91,8 @@ export const DashTeam = ({ user = null }) => {
|
||||
}
|
||||
|
||||
DashTeam.propTypes = {
|
||||
user: PropTypes.any
|
||||
user: PropTypes.any,
|
||||
classes: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
const getUserOnMount = lifecycle({
|
||||
|
||||
Reference in new issue
Block a user