import api from "@/lib/api-client"; export interface RowComment { id: string; workspaceId: string; tableId: string; rowId: string; parentCommentId: string | null; content: Record; authorUserId: string; isResolved: boolean; resolvedAt: string | null; resolvedBy: string | null; createdAt: string; updatedAt: string; author?: { id: string; name: string; avatarUrl: string | null }; resolver?: { id: string; name: string; avatarUrl: string | null }; } export interface ListRowCommentsParams { tableId: string; rowId: string; resolved?: boolean; } export interface CreateRowCommentParams { tableId: string; rowId: string; content: string; parentCommentId?: string; } export async function listRowComments( params: ListRowCommentsParams, ): Promise { const res = await api.get("/v1/row-comments", { params }); return res.data; } export async function createRowComment( params: CreateRowCommentParams, ): Promise { const res = await api.post("/v1/row-comments", params); return res.data; } export async function updateRowComment( commentId: string, content: string, ): Promise { const res = await api.patch(`/v1/row-comments/${commentId}`, { content, }); return res.data; } export async function resolveRowComment( commentId: string, resolved: boolean, ): Promise { const res = await api.patch( `/v1/row-comments/${commentId}/resolve`, { resolved }, ); return res.data; } export async function deleteRowComment(commentId: string): Promise { await api.delete(`/v1/row-comments/${commentId}`); } export async function countRowComments( tableId: string, rowId: string, ): Promise { const res = await api.get<{ count: number }>("/v1/row-comments/count", { params: { tableId, rowId }, }); return res.data.count; }