1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-28 14:16:41 +07:00

added message delete api call

This commit is contained in:
Fedor Katurov 2020-09-08 12:25:52 +07:00
parent 9bdeb5aa0a
commit c2ebde069d
4 changed files with 113 additions and 47 deletions

36
src/redux/messages/api.ts Normal file
View file

@ -0,0 +1,36 @@
import { IMessage, IResultWithStatus } from '~/redux/types';
import { api, configWithToken, errorMiddleware, resultMiddleware } from '~/utils/api';
import { API } from '~/constants/api';
export const apiMessagesGetUserMessages = ({
access,
username,
}): Promise<IResultWithStatus<{ messages: IMessage[] }>> =>
api
.get(API.USER.MESSAGES(username), configWithToken(access))
.then(resultMiddleware)
.catch(errorMiddleware);
export const apiMessagesSendMessage = ({
access,
username,
message,
}): Promise<IResultWithStatus<{ message: IMessage }>> =>
api
.post(API.USER.MESSAGE_SEND(username), { message }, configWithToken(access))
.then(resultMiddleware)
.catch(errorMiddleware);
export const apiMessagesDeleteMessage = ({
access,
username,
id,
}: {
access: string;
username: string;
id: number;
}): Promise<IResultWithStatus<{ message: IMessage }>> =>
api
.delete(API.USER.MESSAGE_DELETE(username, id), configWithToken(access))
.then(resultMiddleware)
.catch(errorMiddleware);