/**
 * Default comment API for the single-post review flow. The popovers
 * (`InlineCommentPopover`, `InlineThreadPopover`) accept this object as the
 * `api` prop with this default so existing call sites keep working unchanged.
 * The site-review chrome (Pro) provides its own implementation that hits the
 * `flow-pro/v1/site-reviews/{id}/comments` namespace with site-review-shaped
 * payloads. Both share the same surface so the popovers stay generic. Surface:
 * postComment( { html, anchorText, blockClientId, parentId } ) → comment row
 * updateComment( id, data ) → comment row
 */
import flowFetch, { pageData } from './api';

export const defaultCommentApi = {
	postComment: ( payload ) =>
		flowFetch( `reviews/${ pageData.reviewId }/comments`, {
			method: 'POST',
			data: payload,
		} ),
	updateComment: ( id, data ) =>
		flowFetch( `comments/${ id }`, {
			method: 'PATCH',
			data,
		} ),
	deleteComment: ( id ) =>
		flowFetch( `comments/${ id }`, {
			method: 'DELETE',
		} ),
};
