Toast type (success/warning/etc)

This commit is contained in:
Tom Moor
2018-05-31 12:07:49 -07:00
parent f633f63a61
commit fb7a8f0312
11 changed files with 58 additions and 36 deletions

View File

@@ -12,6 +12,7 @@ class AuthStore {
@observable user: ?User;
@observable team: ?Team;
@observable token: ?string;
@observable isSaving: boolean = false;
@observable isLoading: boolean = false;
@observable isSuspended: boolean = false;
@observable suspendedContactEmail: ?string;
@@ -50,13 +51,19 @@ class AuthStore {
};
@action
updateUser = async (params: { name: string, avatarUrl?: string }) => {
const res = await client.post(`/user.update`, params);
invariant(res && res.data, 'User response not available');
updateUser = async (params: { name: string, avatarUrl: ?string }) => {
this.isSaving = true;
runInAction('AuthStore#updateUser', () => {
this.user = res.data.user;
});
try {
const res = await client.post(`/user.update`, params);
invariant(res && res.data, 'User response not available');
runInAction('AuthStore#updateUser', () => {
this.user = res.data;
});
} finally {
this.isSaving = false;
}
};
@action