logininfo.actions.ts 1.55 KB
Newer Older
1
import { NgRedux } from "@angular-redux/store";
2
3
4
5
import { Injectable } from "@angular/core";

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

@Injectable()
export class LoginInfoActions {
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    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
                }
            });
        });
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

    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: {
            }
        });
    };
62

63
64

}