import axios from "axios"; import { converObj } from "@/helper"; import { COMMENT_API } from "@/components/comment/config/constant"; type CommonListResponse = { list: Array; total: number; page: number; }; interface CommonResponse { config: any; data: CommonListResponse; headers: any; request: any; status: number; statusText: string; } export const getComment = async ({ type, businessId, isSpeak, page, limit, }: { type: string; businessId: string; isSpeak?: boolean; page: string; limit: string; }): Promise => { const r: CommonResponse = await axios.get( `${COMMENT_API}/comments?${converObj({ type, business_id: businessId, page, limit, })}`, { withCredentials: true } ); return r.data; }; export const createComment = async ({ type, businessId, businessUserId, content, }: { type: string; businessId: string; businessUserId: string; content: string; }): Promise => { const r = await axios.post(`${COMMENT_API}/comments`, { method: "post", withCredentials: true, data: { type, businessId, businessUserId, content, }, }); return r; }; export const updateComment = async ({ id, content, }: { id: string; content: string; }) => { const r = await axios.post(`${COMMENT_API}/comments/${id}`, { method: "post", withCredentials: true, data: { content, }, }); return r; }; export const deleteComment = async ({ id }: { id: string }) => { const r = await axios.delete(`${COMMENT_API}/comments/${id}`); return r; }; export const favorComment = async ({ id, commentId, userId, }: { id: string; commentId: string; userId: number; }) => { const r = await axios(`${COMMENT_API}/comments/${id}/favor`, { method: "put", withCredentials: true, data: { commentID: commentId, userID: userId, }, }); return r; }; export const unFavorComment = async ({ id, commentId, userId, }: { id: string; commentId: string; userId: number; }) => { const r = await axios(`${COMMENT_API}/comments/${id}/favor`, { method: "delete", withCredentials: true, data: { commentID: commentId, userID: userId, }, }); return r; }; // export const getFavorUserList = async () => {}