mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +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;
|
||||
};
|
||||
}>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue