mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added request code dialog
This commit is contained in:
parent
c0c832d158
commit
6dcb21e9e4
18 changed files with 292 additions and 88 deletions
|
@ -1,17 +1,12 @@
|
|||
import {
|
||||
api,
|
||||
errorMiddleware,
|
||||
resultMiddleware,
|
||||
configWithToken
|
||||
} from "~/utils/api";
|
||||
import { API } from "~/constants/api";
|
||||
import { IResultWithStatus, IMessage } from "~/redux/types";
|
||||
import { userLoginTransform } from "~/redux/auth/transforms";
|
||||
import { IUser } from "./types";
|
||||
import { api, errorMiddleware, resultMiddleware, configWithToken } from '~/utils/api';
|
||||
import { API } from '~/constants/api';
|
||||
import { IResultWithStatus, IMessage } from '~/redux/types';
|
||||
import { userLoginTransform } from '~/redux/auth/transforms';
|
||||
import { IUser } from './types';
|
||||
|
||||
export const apiUserLogin = ({
|
||||
username,
|
||||
password
|
||||
password,
|
||||
}: {
|
||||
username: string;
|
||||
password: string;
|
||||
|
@ -22,9 +17,7 @@ export const apiUserLogin = ({
|
|||
.catch(errorMiddleware)
|
||||
.then(userLoginTransform);
|
||||
|
||||
export const apiAuthGetUser = ({
|
||||
access
|
||||
}): Promise<IResultWithStatus<{ user: IUser }>> =>
|
||||
export const apiAuthGetUser = ({ access }): Promise<IResultWithStatus<{ user: IUser }>> =>
|
||||
api
|
||||
.get(API.USER.ME, configWithToken(access))
|
||||
.then(resultMiddleware)
|
||||
|
@ -32,7 +25,7 @@ export const apiAuthGetUser = ({
|
|||
|
||||
export const apiAuthGetUserProfile = ({
|
||||
access,
|
||||
username
|
||||
username,
|
||||
}): Promise<IResultWithStatus<{ user: IUser }>> =>
|
||||
api
|
||||
.get(API.USER.PROFILE(username), configWithToken(access))
|
||||
|
@ -41,7 +34,7 @@ export const apiAuthGetUserProfile = ({
|
|||
|
||||
export const apiAuthGetUserMessages = ({
|
||||
access,
|
||||
username
|
||||
username,
|
||||
}): Promise<IResultWithStatus<{ messages: IMessage[] }>> =>
|
||||
api
|
||||
.get(API.USER.MESSAGES(username), configWithToken(access))
|
||||
|
@ -51,7 +44,7 @@ export const apiAuthGetUserMessages = ({
|
|||
export const apiAuthSendMessage = ({
|
||||
access,
|
||||
username,
|
||||
message
|
||||
message,
|
||||
}): Promise<IResultWithStatus<{ message: IMessage }>> =>
|
||||
api
|
||||
.post(API.USER.MESSAGE_SEND(username), { message }, configWithToken(access))
|
||||
|
@ -61,21 +54,21 @@ export const apiAuthSendMessage = ({
|
|||
export const apiAuthGetUpdates = ({
|
||||
access,
|
||||
exclude_dialogs,
|
||||
last
|
||||
last,
|
||||
}): Promise<IResultWithStatus<{ message: IMessage }>> =>
|
||||
api
|
||||
.get(
|
||||
API.USER.GET_UPDATES,
|
||||
configWithToken(access, { params: { exclude_dialogs, last } })
|
||||
)
|
||||
.get(API.USER.GET_UPDATES, configWithToken(access, { params: { exclude_dialogs, last } }))
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware);
|
||||
|
||||
export const apiUpdateUser = ({
|
||||
access,
|
||||
user
|
||||
}): Promise<IResultWithStatus<{ user: IUser }>> =>
|
||||
export const apiUpdateUser = ({ access, user }): Promise<IResultWithStatus<{ user: IUser }>> =>
|
||||
api
|
||||
.patch(API.USER.ME, { user }, configWithToken(access))
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware);
|
||||
|
||||
export const apiRequestRestoreCode = ({ field }): Promise<IResultWithStatus<{}>> =>
|
||||
api
|
||||
.post(API.USER.REQUEST_CODE(), { field })
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue