import { request, BASE } from "./client";

// ── Types ────────────────────────────────────────────────────────────────────

export interface FollowResponse {
  followed: boolean;
  creator_id: string;
  follower_count: number;
}

export interface FollowStatusResponse {
  following: boolean;
  creator_id: string;
}

export interface FollowedCreatorItem {
  creator_id: string;
  creator_name: string;
  creator_slug: string;
  followed_at: string;
}

// ── Functions ────────────────────────────────────────────────────────────────

export async function followCreator(creatorId: string): Promise<FollowResponse> {
  return request<FollowResponse>(`${BASE}/follows/${creatorId}`, { method: "POST" });
}

export async function unfollowCreator(creatorId: string): Promise<FollowResponse> {
  return request<FollowResponse>(`${BASE}/follows/${creatorId}`, { method: "DELETE" });
}

export async function getFollowStatus(creatorId: string): Promise<FollowStatusResponse> {
  return request<FollowStatusResponse>(`${BASE}/follows/${creatorId}/status`);
}

export async function getMyFollows(): Promise<FollowedCreatorItem[]> {
  return request<FollowedCreatorItem[]>(`${BASE}/follows/me`);
}
