|
@@ -52,7 +52,7 @@ const authorizeUser = async (number:string,country:string):Promise<string | unde
|
|
|
|
|
|
const loginUser = async <T>(number:string,code:string):Promise<T | undefined> => {
|
|
|
try {
|
|
|
- const { data : {data} } = await axios.post('/auth/login', { number,code });
|
|
|
+ const { data : {data} } = await axios.patch('/auth/login', { number,code });
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
return undefined
|
|
@@ -61,7 +61,7 @@ const loginUser = async <T>(number:string,code:string):Promise<T | undefined> =>
|
|
|
|
|
|
const logoutUser = async <T>():Promise<T | undefined> => {
|
|
|
try {
|
|
|
- const { data } = await axios.post('/auth/logout');
|
|
|
+ const { data } = await axios.patch('/auth/logout');
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
forbidden(e)
|
|
@@ -71,7 +71,7 @@ const logoutUser = async <T>():Promise<T | undefined> => {
|
|
|
|
|
|
const onlineUser = async <T>():Promise<T | undefined> => {
|
|
|
try {
|
|
|
- const { data } = await axios.post('/auth/online');
|
|
|
+ const { data } = await axios.patch('/auth/online');
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
forbidden(e)
|
|
@@ -129,9 +129,9 @@ const getContacts = async <T>(): Promise<T | undefined> => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const startChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
+const getChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
try {
|
|
|
- const { data : {data} } = await axios.post('/chats',{id});
|
|
|
+ const { data: { data } } = await axios.get(`/chats/${id}`);
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
forbidden(e)
|
|
@@ -139,9 +139,9 @@ const startChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const getChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
+const startChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
try {
|
|
|
- const { data: { data } } = await axios.get(`/chats/${id}`);
|
|
|
+ const { data : {data} } = await axios.post('/chats',{id});
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
forbidden(e)
|
|
@@ -151,7 +151,7 @@ const getChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
|
|
|
const muteChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
try {
|
|
|
- const { data: { data } } = await axios.post('/chats/mute', {id});
|
|
|
+ const { data: { data } } = await axios.patch('/chats/mute', {id});
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
forbidden(e)
|
|
@@ -161,7 +161,7 @@ const muteChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
|
|
|
const seenChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
try {
|
|
|
- const { data: { data } } = await axios.post('/chats/seen', { id });
|
|
|
+ const { data: { data } } = await axios.patch('/chats/seen', { id });
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
forbidden(e)
|
|
@@ -171,7 +171,7 @@ const seenChat = async <T>(id:string): Promise<T | undefined> => {
|
|
|
|
|
|
const typingChat = async <T>(id:string,typing:boolean): Promise<T | undefined> => {
|
|
|
try {
|
|
|
- const { data: { data } } = await axios.post('/chats/typing', { id,typing});
|
|
|
+ const { data: { data } } = await axios.patch('/chats/typing', { id,typing});
|
|
|
return data
|
|
|
} catch (e) {
|
|
|
forbidden(e)
|
|
@@ -199,6 +199,16 @@ const sentMessageById = async <T>(id:string,message:any): Promise<T | undefined>
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const sentImgMessageById = async <T>(id:string,formData: object): Promise<T | undefined> => {
|
|
|
+ try {
|
|
|
+ const { data: { data } } = await axios.post(`/messages/img/${id}`, formData);
|
|
|
+ return data
|
|
|
+ } catch (e) {
|
|
|
+ forbidden(e)
|
|
|
+ return undefined
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const getMessagesById = async <T>(id:string): Promise<T | undefined> => {
|
|
|
try {
|
|
|
const { data : {data} } = await axios.get(`/messages/${id}`);
|
|
@@ -229,5 +239,6 @@ export {
|
|
|
typingChat,
|
|
|
getChats,
|
|
|
sentMessageById,
|
|
|
+ sentImgMessageById,
|
|
|
getMessagesById
|
|
|
};
|