Add basic services; Base layout
This commit is contained in:
parent
be6467cd2c
commit
ef526cd2db
30 changed files with 291 additions and 34 deletions
28
src/store/auth/auth.ts
Normal file
28
src/store/auth/auth.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { fetchLogin, fetchRefresh } from "../../services/auth";
|
||||
import { AuthActionTypes, AuthAction } from "./actions";
|
||||
import { IAuthState } from "./types";
|
||||
|
||||
function authReducer(state: IAuthState, action: AuthAction): IAuthState {
|
||||
switch (action.type) {
|
||||
case AuthActionTypes.FETCH_LOGIN_START:
|
||||
fetchLogin(action.payload.username, action.payload.password);
|
||||
return state;
|
||||
case AuthActionTypes.FETCH_LOGIN_FINISH:
|
||||
return {
|
||||
...state,
|
||||
session: action.payload,
|
||||
};
|
||||
case AuthActionTypes.FETCH_REFRESH_START:
|
||||
fetchRefresh();
|
||||
return state;
|
||||
case AuthActionTypes.FETCH_REFRESH_FINISH:
|
||||
return {
|
||||
...state,
|
||||
session: action.payload,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export { authReducer };
|
||||
Loading…
Add table
Add a link
Reference in a new issue