fb-test-module
Version:
How to use: ``` import {store, getStore} from 'fb-test-module'; conf.DialogramApi = "API_BASE_URL"; conf.Platform = "mobile"; //use "web" if you are on webApp getStore(); //Inject store in your provider ``` and you'r readyt to go. # Base ## Act
68 lines (63 loc) • 1.9 kB
text/typescript
import { store } from '../index';
export default class UserHelper {
static getUserId() {
const state = store.getState()['user'];
if (!state) {
throw new Error('State initialization error');
}
if (!state.get('user')) {
return null;
}
return state.get('user').first().get('id');
}
static getUserStatus() {
const state = store.getState()['user'];
if (!state) {
throw new Error('State initialization error');
}
if (!state.get('status')) {
return null;
}
return state.get('status');
}
static getUserError() {
const state = store.getState()['user'];
if (!state) {
throw new Error('State initialization error');
}
if (!state.get('error')) {
return null;
}
return state.get('error');
}
static getUserNickname() {
const state = store.getState()['user'];
if (!state) {
throw new Error('State initialization error');
}
if (!state.get('user')) {
return null;
}
return state.get('user').first().get('nickName')
}
static getUserProfile() {
const state = store.getState()['user'];
if (!state) {
throw new Error('State initialization error');
}
if (!state.get('user')) {
return null;
}
return state.get('user').first().get('profile').toJS();
}
static getUserEmail() {
const state = store.getState()['user'];
if (!state) {
throw new Error('State initialization error');
}
if (!state.get('user')) {
return null;
}
return state.get('user').first().get('email');
}
}