logininfo.actions.ts 1.32 KB
Newer Older
1
import { LOGININFO_SAVE, PROFILE_SAVE, LOGININFO_RECEIVED, STATEMENTAGREE_SAVE } from '../constants';
Open Source Developer's avatar
Open Source Developer committed
2
import { LOGININFO_INIT } from '../constants';
3
import { Injectable } from '@angular/core';
4
import { NgRedux } from '@angular-redux/store';
5 6 7 8 9 10 11 12 13
import { IAppState } from '../store';
import { HelperDataService } from '../services/helper-data-service';

@Injectable()
export class LoginInfoActions {
  constructor(
    private _ngRedux: NgRedux<IAppState>,
    private _hds: HelperDataService) {}

14

Open Source Developer's avatar
Open Source Developer committed
15
 getloginInfo = (loginInfo) => {
16
 return this._hds.getCurrentUser(loginInfo.auth_token, loginInfo.auth_role).then (loginInfos => {
17 18 19
      return this._ngRedux.dispatch({
        type: LOGININFO_SAVE,
        payload: {
20
          loginInfos
21 22
        }
      });
23
  });
Open Source Developer's avatar
Open Source Developer committed
24
}
25

26 27 28 29 30 31 32 33 34
 saveMinEduloginInfo = (loginInfos) => {
   return this._ngRedux.dispatch({
    type: LOGININFO_SAVE,
    payload: {
      loginInfos
    }
  });
};

35 36 37 38 39 40 41 42 43
saveProfile = (profile) => {
  return this._ngRedux.dispatch({
   type: PROFILE_SAVE,
   payload: {
     profile
   }
 });
};

44 45 46 47 48 49 50 51 52
saveStatementAgree = (disclaimer_checked) => {
  return this._ngRedux.dispatch({
   type: STATEMENTAGREE_SAVE,
   payload: {
     disclaimer_checked
   }
 });
};

53

54 55 56 57 58 59 60 61
  initLoginInfo = () => {
      return this._ngRedux.dispatch({
          type: LOGININFO_INIT,
          payload: {
          }
      });
  };

62 63

}