diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-05-26 09:46:18 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-05-26 09:46:18 -0400 |
commit | 6fecfcc7ca9f7cf29b4cf87ebeb63b09df70a8c7 (patch) | |
tree | d0d8d9833156f2a21f37a1ff746acd18342d3ebe /webapp/actions/team_actions.jsx | |
parent | 9c0caaa76505d4d473f987298acace4f198eb447 (diff) | |
download | chat-6fecfcc7ca9f7cf29b4cf87ebeb63b09df70a8c7.tar.gz chat-6fecfcc7ca9f7cf29b4cf87ebeb63b09df70a8c7.tar.bz2 chat-6fecfcc7ca9f7cf29b4cf87ebeb63b09df70a8c7.zip |
Refactor login, claim and create_team into views and add actions (#3110)
Diffstat (limited to 'webapp/actions/team_actions.jsx')
-rw-r--r-- | webapp/actions/team_actions.jsx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/webapp/actions/team_actions.jsx b/webapp/actions/team_actions.jsx new file mode 100644 index 000000000..2408e55fd --- /dev/null +++ b/webapp/actions/team_actions.jsx @@ -0,0 +1,38 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import UserStore from 'stores/user_store.jsx'; + +import Constants from 'utils/constants.jsx'; +const ActionTypes = Constants.ActionTypes; + +import * as AsyncClient from 'utils/async_client.jsx'; +import Client from 'utils/web_client.jsx'; +import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; + +import {browserHistory} from 'react-router'; + +export function checkIfTeamExists(teamName, onSuccess, onError) { + Client.findTeamByName(teamName, onSuccess, onError); +} + +export function createTeam(team, onSuccess, onError) { + Client.createTeam(team, + (rteam) => { + AsyncClient.getDirectProfiles(); + + AppDispatcher.handleServerAction({ + type: ActionTypes.CREATED_TEAM, + team: rteam, + member: {team_id: rteam.id, user_id: UserStore.getCurrentId(), roles: 'admin'} + }); + + browserHistory.push('/' + rteam.name + '/channels/town-square'); + + if (onSuccess) { + onSuccess(rteam); + } + }, + onError + ); +} |