mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added register_socials to reducer
This commit is contained in:
parent
358b197c19
commit
837b4ee6f3
8 changed files with 1471 additions and 1412 deletions
|
@ -138,3 +138,15 @@ export const authGotOauthEvent = (event: IOAuthEvent) => ({
|
|||
type: AUTH_USER_ACTIONS.GOT_OAUTH_EVENT,
|
||||
event,
|
||||
});
|
||||
|
||||
export const authSetRegisterSocial = (register_social: Partial<IAuthState['register_social']>) => ({
|
||||
type: AUTH_USER_ACTIONS.SET_REGISTER_SOCIAL,
|
||||
register_social,
|
||||
});
|
||||
|
||||
export const authSetRegisterSocialErrors = (
|
||||
errors: Partial<IAuthState['register_social']['errors']>
|
||||
) => ({
|
||||
type: AUTH_USER_ACTIONS.SET_REGISTER_SOCIAL_ERRORS,
|
||||
errors,
|
||||
});
|
||||
|
|
|
@ -32,6 +32,9 @@ export const AUTH_USER_ACTIONS = {
|
|||
ATTACH_SOCIAL: 'ATTACH_SOCIAL',
|
||||
LOGIN_WITH_SOCIAL: 'LOGIN_WITH_SOCIAL',
|
||||
GOT_OAUTH_EVENT: 'GOT_OAUTH_EVENT',
|
||||
|
||||
SET_REGISTER_SOCIAL: 'SET_REGISTER_SOCIAL',
|
||||
SET_REGISTER_SOCIAL_ERRORS: 'SET_REGISTER_SOCIAL_ERRORS',
|
||||
};
|
||||
|
||||
export const USER_ERRORS = {
|
||||
|
|
|
@ -64,6 +64,7 @@ const setRestore: ActionHandler<typeof ActionCreators.authSetRestore> = (state,
|
|||
...restore,
|
||||
},
|
||||
});
|
||||
|
||||
const setSocials: ActionHandler<typeof ActionCreators.authSetSocials> = (state, { socials }) => ({
|
||||
...state,
|
||||
profile: {
|
||||
|
@ -75,6 +76,31 @@ const setSocials: ActionHandler<typeof ActionCreators.authSetSocials> = (state,
|
|||
},
|
||||
});
|
||||
|
||||
const setRegisterSocial: ActionHandler<typeof ActionCreators.authSetRegisterSocial> = (
|
||||
state,
|
||||
{ register_social }
|
||||
) => ({
|
||||
...state,
|
||||
register_social: {
|
||||
...state.register_social,
|
||||
...register_social,
|
||||
},
|
||||
});
|
||||
|
||||
const setRegisterSocialErrors: ActionHandler<typeof ActionCreators.authSetRegisterSocialErrors> = (
|
||||
state,
|
||||
{ errors }
|
||||
) => ({
|
||||
...state,
|
||||
register_social: {
|
||||
...state.register_social,
|
||||
errors: {
|
||||
...state.register_social.errors,
|
||||
...errors,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const AUTH_USER_HANDLERS = {
|
||||
[AUTH_USER_ACTIONS.SET_LOGIN_ERROR]: setLoginError,
|
||||
[AUTH_USER_ACTIONS.SET_USER]: setUser,
|
||||
|
@ -84,4 +110,6 @@ export const AUTH_USER_HANDLERS = {
|
|||
[AUTH_USER_ACTIONS.SET_LAST_SEEN_MESSAGES]: setLastSeenMessages,
|
||||
[AUTH_USER_ACTIONS.SET_RESTORE]: setRestore,
|
||||
[AUTH_USER_ACTIONS.SET_SOCIALS]: setSocials,
|
||||
[AUTH_USER_ACTIONS.SET_REGISTER_SOCIAL]: setRegisterSocial,
|
||||
[AUTH_USER_ACTIONS.SET_REGISTER_SOCIAL_ERRORS]: setRegisterSocialErrors,
|
||||
};
|
||||
|
|
|
@ -47,6 +47,16 @@ const INITIAL_STATE: IAuthState = {
|
|||
is_succesfull: false,
|
||||
error: null,
|
||||
},
|
||||
|
||||
register_social: {
|
||||
errors: {
|
||||
username: '',
|
||||
password: '',
|
||||
},
|
||||
error: '',
|
||||
token: '',
|
||||
is_loading: false,
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(INITIAL_STATE, HANDLERS);
|
|
@ -74,4 +74,14 @@ export type IAuthState = Readonly<{
|
|||
is_succesfull: boolean;
|
||||
error: string;
|
||||
};
|
||||
|
||||
register_social: {
|
||||
errors: {
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
error: string;
|
||||
token: string;
|
||||
is_loading: boolean;
|
||||
};
|
||||
}>;
|
||||
|
|
|
@ -7,7 +7,7 @@ import { connectRouter, RouterState, routerMiddleware } from 'connected-react-ro
|
|||
import { createBrowserHistory } from 'history';
|
||||
import { PersistConfig, Persistor } from 'redux-persist/es/types';
|
||||
|
||||
import auth from '~/redux/auth/reducer';
|
||||
import auth from '~/redux/auth';
|
||||
import authSaga from '~/redux/auth/sagas';
|
||||
import { IAuthState } from '~/redux/auth/types';
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// create-reducer.ts
|
||||
// create-index.ts
|
||||
import { Action } from 'redux';
|
||||
|
||||
type Handlers<State, Types extends string, Actions extends Action<Types>> = {
|
||||
readonly [Type in Types]: (state: State, action: Actions) => State
|
||||
}
|
||||
readonly [Type in Types]: (state: State, action: Actions) => State;
|
||||
};
|
||||
|
||||
// export const createReducer = <State, Types extends string, Actions extends Action<Types>>(
|
||||
// initialState: State,
|
||||
|
@ -11,9 +11,5 @@ type Handlers<State, Types extends string, Actions extends Action<Types>> = {
|
|||
// ) => (state = initialState, action: Actions) =>
|
||||
// handlers.hasOwnProperty(action.type) ? handlers[action.type as Types](state, action) : state;
|
||||
|
||||
export const createReducer = (
|
||||
initialState,
|
||||
handlers,
|
||||
) => (state = initialState, action) => (handlers.hasOwnProperty(action.type)
|
||||
? handlers[action.type](state, action)
|
||||
: state);
|
||||
export const createReducer = (initialState, handlers) => (state = initialState, action) =>
|
||||
handlers.hasOwnProperty(action.type) ? handlers[action.type](state, action) : state;
|
||||
|
|
2804
yarn-error.log
2804
yarn-error.log
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue