logininfo.actions.ts 1.55 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
import { NgRedux } from "@angular-redux/store";
import { Injectable } from "@angular/core";

import { LOGININFO_SAVE, PROFILE_SAVE, STATEMENTAGREE_SAVE } from "../constants";
import { LOGININFO_INIT } from "../constants";
import { HelperDataService } from "../services/helper-data-service";
import { IAppState } from "../store";

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


    getloginInfo = (loginInfo) => {
        return this._hds.getCurrentUser(loginInfo.auth_token, loginInfo.auth_role).then(loginInfos => {
            return this._ngRedux.dispatch({
                type: LOGININFO_SAVE,
                payload: {
                    loginInfos
                }
            });
        });
    }

    saveMinEduloginInfo = (loginInfos) => {
        return this._ngRedux.dispatch({
            type: LOGININFO_SAVE,
            payload: {
                loginInfos
            }
        });
    };

    saveProfile = (profile) => {
        return this._ngRedux.dispatch({
            type: PROFILE_SAVE,
            payload: {
                profile
            }
        });
    };

    saveStatementAgree = (disclaimer_checked) => {
        return this._ngRedux.dispatch({
            type: STATEMENTAGREE_SAVE,
            payload: {
                disclaimer_checked
            }
        });
    };


    initLoginInfo = () => {
        return this._ngRedux.dispatch({
            type: LOGININFO_INIT,
            payload: {
            }
        });
    };


}