Skip to content

Commit

Permalink
Merge pull request #101 from developmentseed/create-team-fix
Browse files Browse the repository at this point in the history
replace placeholder createTeam function with link to /teams/create
  • Loading branch information
kamicut authored Aug 23, 2019
2 parents 06b7a9e + 6fd188c commit b09ab07
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions pages/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import Router from 'next/router'
import join from 'url-join'
import getConfig from 'next/config'
import Button from '../components/button'
import Chance from 'chance'
import Section from '../components/section'
import SectionHeader from '../components/section-header'
import Table from '../components/table'
import { getTeams } from '../lib/teams-api'
const chance = Chance()

const { publicRuntimeConfig } = getConfig()
const URL = publicRuntimeConfig.APP_URL
Expand Down Expand Up @@ -41,27 +39,6 @@ export default class Profile extends Component {
}
}

async createTeam () {
let res = await fetch(join(URL, '/api/teams'), {
method: 'POST',
body: JSON.stringify({
name: `${chance.country({ full: true })} ${chance.animal()} ${chance.pickone([
'Group', 'Inc.', 'Ltd.', 'Team', 'Associates', 'Party', 'LLC', 'Corp.'
]
)}`,
hashtag: chance.hashtag()
}),
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
})
if (res.status === 200) {
await this.refreshTeams()
} else {
throw new Error('Could not create new team')
}
}

componentDidMount () {
this.refreshTeams()
}
Expand Down Expand Up @@ -97,7 +74,7 @@ export default class Profile extends Component {
<div className='inner page'>
<div className='page__heading'>
<h2>Profile</h2>
<Button variant='primary' onClick={() => this.createTeam()} >Create team</Button>
<Button variant='primary' href='/teams/create' >Create team</Button>
</div>
<Section>
<SectionHeader>Your Teams</SectionHeader>
Expand Down

0 comments on commit b09ab07

Please sign in to comment.