1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

#23 added superpowers switch

This commit is contained in:
Fedor Katurov 2021-03-19 14:15:04 +07:00
parent e38090c755
commit 756840f173
16 changed files with 178 additions and 25 deletions

View file

@ -20,6 +20,11 @@ export const authSetToken = (token: IAuthState['token']) => ({
token,
});
export const authSetState = (payload: Partial<IAuthState>) => ({
type: AUTH_USER_ACTIONS.SET_STATE,
payload,
});
export const gotAuthPostMessage = ({ token }: { token: string }) => ({
type: AUTH_USER_ACTIONS.GOT_AUTH_POST_MESSAGE,
token,

View file

@ -1,6 +1,5 @@
import { api, cleanResult, errorMiddleware, resultMiddleware } from '~/utils/api';
import { api, cleanResult } from '~/utils/api';
import { API } from '~/constants/api';
import { IResultWithStatus } from '~/redux/types';
import {
ApiAttachSocialRequest,
ApiAttachSocialResult,

View file

@ -3,6 +3,7 @@ import { IToken, IUser } from '~/redux/auth/types';
export const AUTH_USER_ACTIONS = {
SEND_LOGIN_REQUEST: 'SEND_LOGIN_REQUEST',
SET_LOGIN_ERROR: 'SET_LOGIN_ERROR',
SET_STATE: 'SET_STATE',
SET_USER: 'SET_USER',
SET_TOKEN: 'SET_TOKEN',

View file

@ -25,6 +25,11 @@ const setUser: ActionHandler<typeof ActionCreators.authSetUser> = (state, { prof
},
});
const setState: ActionHandler<typeof ActionCreators.authSetState> = (state, { payload }) => ({
...state,
...payload,
});
const setToken: ActionHandler<typeof ActionCreators.authSetToken> = (state, { token }) => ({
...state,
token,
@ -104,6 +109,7 @@ const setRegisterSocialErrors: ActionHandler<typeof ActionCreators.authSetRegist
export const AUTH_USER_HANDLERS = {
[AUTH_USER_ACTIONS.SET_LOGIN_ERROR]: setLoginError,
[AUTH_USER_ACTIONS.SET_USER]: setUser,
[AUTH_USER_ACTIONS.SET_STATE]: setState,
[AUTH_USER_ACTIONS.SET_TOKEN]: setToken,
[AUTH_USER_ACTIONS.SET_PROFILE]: setProfile,
[AUTH_USER_ACTIONS.SET_UPDATES]: setUpdates,

View file

@ -10,6 +10,7 @@ const HANDLERS = {
const INITIAL_STATE: IAuthState = {
token: '',
user: { ...EMPTY_USER },
is_tester: false,
updates: {
last: '',

View file

@ -2,6 +2,7 @@ import { IState } from '~/redux/store';
export const selectAuth = (state: IState) => state.auth;
export const selectUser = (state: IState) => state.auth.user;
export const selectAuthIsTester = (state: IState) => state.auth.is_tester;
export const selectToken = (state: IState) => state.auth.token;
export const selectAuthLogin = (state: IState) => state.auth.login;
export const selectAuthProfile = (state: IState) => state.auth.profile;

View file

@ -37,6 +37,8 @@ export type IAuthState = Readonly<{
user: IUser;
token: string;
is_tester: boolean;
updates: {
last: string;
notifications: INotification[];

View file

@ -46,7 +46,7 @@ import { assocPath } from 'ramda';
const authPersistConfig: PersistConfig = {
key: 'auth',
whitelist: ['token', 'user', 'updates'],
whitelist: ['token', 'user', 'updates', 'is_tester'],
storage,
};