import { apiClient } from "@/api/client"; export interface Comment { idComment: number; content: string; dateOfComment: string; patientId: number; patientUsername: string; patientName: string; } export interface BlogPost { idBlog: number; title: string; content: string; dateOfPost: string; patientId: number; patientUsername: string; patientName: string; likesCount: number; commentsCount: number; likedByCurrentUser: boolean; comments: Comment[]; } export interface CreateBlogRequest { title: string; content: string; } export interface UpdateBlogRequest { title: string; content: string; } export const blogApi = { getAllBlogs: async (): Promise => apiClient.get("/blogs"), getBlog: async (id: number): Promise => apiClient.get(`/blogs/${id}`), createBlog: async (data: CreateBlogRequest): Promise => apiClient.post("/blogs", data), updateBlog: async (id: number, data: UpdateBlogRequest): Promise => apiClient.put(`/blogs/${id}`, data), deleteBlog: async (id: number): Promise => apiClient.delete(`/blogs/${id}`), toggleLike: async (id: number): Promise => apiClient.post(`/blogs/${id}/like`), addComment: async (blogId: number, content: string): Promise => apiClient.post(`/blogs/${blogId}/comments`, { content }), updateComment: async (commentId: number, content: string): Promise => apiClient.put(`/blogs/comments/${commentId}`, { content }), deleteComment: async (commentId: number): Promise => apiClient.delete(`/blogs/comments/${commentId}`), };