mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
78 lines
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
import { AUTH_USER_ACTIONS } from '~/redux/auth/constants';
|
|
import { IAuthState, IUser } from '~/redux/auth/types';
|
|
import { IMessage } from '../types';
|
|
|
|
export const userSendLoginRequest = ({
|
|
username,
|
|
password,
|
|
}: {
|
|
username: string;
|
|
password: string;
|
|
}) => ({ type: AUTH_USER_ACTIONS.SEND_LOGIN_REQUEST, username, password });
|
|
|
|
export const userSetLoginError = (error: IAuthState['login']['error']) => ({
|
|
type: AUTH_USER_ACTIONS.SET_LOGIN_ERROR,
|
|
error,
|
|
});
|
|
|
|
export const authSetToken = (token: IAuthState['token']) => ({
|
|
type: AUTH_USER_ACTIONS.SET_TOKEN,
|
|
token,
|
|
});
|
|
|
|
export const gotAuthPostMessage = ({ token }: { token: string }) => ({
|
|
type: AUTH_USER_ACTIONS.GOT_AUTH_POST_MESSAGE,
|
|
token,
|
|
});
|
|
|
|
export const authSetUser = (profile: Partial<IUser>) => ({
|
|
type: AUTH_USER_ACTIONS.SET_USER,
|
|
profile,
|
|
});
|
|
|
|
export const authLogout = () => ({
|
|
type: AUTH_USER_ACTIONS.LOGOUT,
|
|
});
|
|
|
|
export const authLoggedIn = () => ({
|
|
type: AUTH_USER_ACTIONS.LOGGED_IN,
|
|
});
|
|
|
|
export const authOpenProfile = (username: string, tab?: IAuthState['profile']['tab']) => ({
|
|
type: AUTH_USER_ACTIONS.OPEN_PROFILE,
|
|
username,
|
|
tab,
|
|
});
|
|
|
|
export const authSetProfile = (profile: Partial<IAuthState['profile']>) => ({
|
|
type: AUTH_USER_ACTIONS.SET_PROFILE,
|
|
profile,
|
|
});
|
|
|
|
export const authGetMessages = (username: string) => ({
|
|
type: AUTH_USER_ACTIONS.GET_MESSAGES,
|
|
username,
|
|
});
|
|
|
|
export const authSendMessage = (message: Partial<IMessage>, onSuccess) => ({
|
|
type: AUTH_USER_ACTIONS.SEND_MESSAGE,
|
|
message,
|
|
onSuccess,
|
|
});
|
|
|
|
export const authSetUpdates = (updates: Partial<IAuthState['updates']>) => ({
|
|
type: AUTH_USER_ACTIONS.SET_UPDATES,
|
|
updates,
|
|
});
|
|
|
|
export const authSetLastSeenMessages = (
|
|
last_seen_messages: IAuthState['user']['last_seen_messages']
|
|
) => ({
|
|
type: AUTH_USER_ACTIONS.SET_LAST_SEEN_MESSAGES,
|
|
last_seen_messages,
|
|
});
|
|
|
|
export const authPatchUser = (user: Partial<IUser>) => ({
|
|
type: AUTH_USER_ACTIONS.PATCH_USER,
|
|
user,
|
|
});
|