Add edit message

This commit is contained in:
2026-01-24 13:20:45 +03:00
parent a690116399
commit 8c0c063bac
17 changed files with 1237 additions and 112 deletions
+58
View File
@@ -0,0 +1,58 @@
import apiClient from './api';
export type Chat = {
chat_id: string;
user_id: number;
last_message: string | null;
avatar_url: string | null;
display_name: string;
}
export type Message = {
id: string;
sender_id: number;
chat_id: string;
content: string;
is_edited?: boolean;
created_at: string;
updated_at: string;
}
export type MessageCreate = {
content: string;
chat_id?: string;
recipient_id?: number;
}
export type MessageUpdate = {
id: string;
content: string;
}
const chatService = {
async getChats(offset: number = 0, limit: number = 10): Promise<Chat[]> {
const response = await apiClient.get('/chats/', {
params: { offset, limit }
});
return response.data;
},
async getChatMessages(chatId: string, offset: number = 0, limit: number = 50): Promise<Message[]> {
const response = await apiClient.get(`/chats/${chatId}`, {
params: { offset, limit }
});
return response.data;
},
async sendMessage(data: MessageCreate): Promise<Message> {
const response = await apiClient.post('/chats/message', data);
return response.data;
},
async updateMessage(data: MessageUpdate): Promise<Message> {
const response = await apiClient.put('/chats/message', data);
return response.data;
}
};
export default chatService;
+5
View File
@@ -26,6 +26,11 @@ export const userService = {
return response.data;
},
getUserById: async (userId: number): Promise<User> => {
const response = await apiClient.get(`/users/${userId}`);
return response.data;
},
updateProfile: async (data: UserUpdate): Promise<User> => {
const response = await apiClient.put('/users/me', data);
return response.data;