From f74d47acb7ee470e24245667c9195604faa66a20 Mon Sep 17 00:00:00 2001 From: haraldox Date: Fri, 2 Feb 2018 11:01:38 +0100 Subject: got server callback and infobox working --- src/stores/UserStore.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/stores/UserStore.js') diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 152090f46..82eab9f44 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js @@ -8,6 +8,8 @@ import Request from './lib/Request'; import CachedRequest from './lib/CachedRequest'; import { gaEvent } from '../lib/analytics'; +import { matchPath } from 'react-router' + // TODO: split stores into UserStore and AuthStore export default class UserStore extends Store { BASE_ROUTE = '/auth'; @@ -161,15 +163,18 @@ export default class UserStore extends Store { gaEvent('User', 'retrievePassword'); } - @action _invite({ invites, from }) { + // TODO: REFACTOR from -> fromRoute + @action async _invite({ invites, from }) { const data = invites.filter(invite => invite.email !== ''); - this.inviteRequest.execute(data); + const response = await this.inviteRequest.execute(data)._promise; - console.log(from) + this.actionStatus = response.status || [] - // we do not wait for a server response before redirecting the user - this.stores.router.push(from + '?success=true' || '/'); + // we do not wait for a server response before redirecting the user ONLY DURING SIGNUP + if (this.stores.router.location.pathname.includes(this.INVITE_ROUTE)) { + this.stores.router.push('/'); + } gaEvent('User', 'inviteUsers'); } -- cgit v1.2.3-54-g00ecf