UNPKG

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

70 lines (65 loc) 2 kB
import { store } from '../index'; import Immutable from 'immutable'; export default class SessionHelper { static getSessionStatus() { const state = store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('status')) { return null; } return state.get('status'); }; static getSessionToken() { const state = store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('session')) { return null; } if (!state.get('session').first()) return null; return state.get('session').first().get('token'); } static getSessionId() { const state = store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('session')) { return null; } if (!state.get('session').first()) return null; return state.get('session').first().get('id'); } static getSessionUserId() { const state = store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('session')) { return null; } if (!state.get('session').first()) return null; return state.get('session').first().get('user'); } static getSessionError() { const state = store.getState()['session']; if (!state) { throw new Error('State initialization error'); return null; } if (!state.get('error')) { return null; } return state.get('error'); } }