From 59028023a827ff5ce853f6fc64f742d6f9ff789e Mon Sep 17 00:00:00 2001 From: Barry Low Date: Sun, 16 Sep 2018 23:29:23 -0700 Subject: [PATCH] Client: Manage Team Edit Details Dialog --- api/database/datamodel.graphql | 1 + api/src/index.js | 2 +- client/src/views/common/MessageCard.js | 2 +- .../dashboard/components/CreateTeamDialog.js | 2 +- .../views/dashboard/components/DashTeam.js | 2 +- .../dashboard/components/ManageTeamEdit.js | 35 ++++++++----------- .../dashboard/components/ManageTeamsList.js | 4 +-- 7 files changed, 21 insertions(+), 27 deletions(-) diff --git a/api/database/datamodel.graphql b/api/database/datamodel.graphql index 7a55f466d..ddc89814c 100644 --- a/api/database/datamodel.graphql +++ b/api/database/datamodel.graphql @@ -42,6 +42,7 @@ type TeamProfile { motto: String avatar: String updatedAt: DateTime! + createdAt: DateTime! } type TeamStatus { diff --git a/api/src/index.js b/api/src/index.js index 8f3670a7a..d640b8682 100644 --- a/api/src/index.js +++ b/api/src/index.js @@ -94,7 +94,7 @@ const resolvers = { return member }, async createTeam(parent, { name, slug, owner }, ctx, info) { - return ctx.db.mutation.createTeam({ data: { name: name, slug: slug, owner: owner, members: { create: { member:{ connect:{ authId: owner} }, role: 'OWNER' } } } }, TEAMS_FRAGMENT) + return ctx.db.mutation.createTeam({ data: { name: name, slug: slug, owner: owner, members: { create: { member:{ connect:{ authId: owner} }, role: 'OWNER' } }, profile:{create:{avatar:"a"} } } }, TEAMS_FRAGMENT) .catch((err) => { console.log('createTeam error: ', err) return err diff --git a/client/src/views/common/MessageCard.js b/client/src/views/common/MessageCard.js index 60668fd62..9c45891d0 100644 --- a/client/src/views/common/MessageCard.js +++ b/client/src/views/common/MessageCard.js @@ -37,7 +37,7 @@ export const MessageCard = ({ classes, message, children }) => ( MessageCard.propTypes = { children: PropTypes.node, classes: PropTypes.object.isRequired, - message: PropTypes.string.isRequired + message: PropTypes.string } export default withStyles(styles)(MessageCard) diff --git a/client/src/views/dashboard/components/CreateTeamDialog.js b/client/src/views/dashboard/components/CreateTeamDialog.js index 66e0f00e5..4db5b5638 100644 --- a/client/src/views/dashboard/components/CreateTeamDialog.js +++ b/client/src/views/dashboard/components/CreateTeamDialog.js @@ -109,7 +109,7 @@ export class CreateTeamDialog extends Component { fullWidth value={this.state.name} onChange={this.handleChange} - error={e => this.state.errors.name !== '' || error} + error={this.state.errors.name !== '' || error} /> {this.state.errors.name !== '' && ({this.state.errors.name})} {error && ({errors})} diff --git a/client/src/views/dashboard/components/DashTeam.js b/client/src/views/dashboard/components/DashTeam.js index 8201e9d4d..1213f7eb1 100644 --- a/client/src/views/dashboard/components/DashTeam.js +++ b/client/src/views/dashboard/components/DashTeam.js @@ -74,7 +74,7 @@ export const DashTeam = ({ classes, user = null }) => { } else { return ( - + diff --git a/client/src/views/dashboard/components/ManageTeamEdit.js b/client/src/views/dashboard/components/ManageTeamEdit.js index 6937cc7f9..6fc498144 100644 --- a/client/src/views/dashboard/components/ManageTeamEdit.js +++ b/client/src/views/dashboard/components/ManageTeamEdit.js @@ -38,21 +38,20 @@ export class ManageTeamEdit extends Component { render () { console.log(this.props, this.props.slug) + const { authId } = this.props return ( { - const data = cache.readQuery({ query: GET_TEAMS_BY_OWNER }) - console.log('Mutation cache update: ', deleteTeam, data) - data.getTeamsByOwner.push(deleteTeam) - cache.writeQuery({ query: GET_TEAMS_BY_OWNER, data }) - }} + refetchQueries={[ + { + query: GET_TEAMS_BY_OWNER, + variables: { authId } + } + ]} > {(updateTeamProfile, { loading, error, data }) => { let errors let loader - let description - let motto if (loading) { loader = Submitting team... } @@ -84,21 +83,17 @@ export class ManageTeamEdit extends Component { { - motto = node - }} /> Team description: { - description = node - }} /> {loader} {errors} @@ -118,7 +110,7 @@ export class ManageTeamEdit extends Component { Cancel @@ -151,18 +143,19 @@ export class ManageTeamEdit extends Component { } } - async handleSubmit (e, updateTeamProfile, slug, description, motto) { + async handleSubmit (e, updateTeamProfile, slug) { e.preventDefault() const currentUser = await getItem('user') let authId = JSON.parse(currentUser) authId = authId.authId - await updateTeamProfile({ variables: { slug, owner: authId, description: description, motto: motto } }) + await updateTeamProfile({ variables: { slug, owner: authId, description: this.state.description, motto: this.state.motto } }) } } ManageTeamEdit.propTypes = { classes: PropTypes.object.isRequired, - slug: PropTypes.string.isRequired + slug: PropTypes.string.isRequired, + authId: PropTypes.string } export default withRouter(ManageTeamEdit) diff --git a/client/src/views/dashboard/components/ManageTeamsList.js b/client/src/views/dashboard/components/ManageTeamsList.js index 6a6bebde4..5a5349e86 100644 --- a/client/src/views/dashboard/components/ManageTeamsList.js +++ b/client/src/views/dashboard/components/ManageTeamsList.js @@ -102,7 +102,7 @@ export const ManageTeamsList = ({ classes, user = null }) => { } else { return ( - + @@ -113,7 +113,7 @@ export const ManageTeamsList = ({ classes, user = null }) => { } else { return ( - + if (errors !== null) ()