// User channel-tags: list + CRUD. Only touches core's req.
import { req } from "./core";

export interface Tag {
  id: number;
  name: string;
  color: string | null;
  category: string;
  system: boolean;
  channel_count: number;
}

export const tagsApi = {
  tags: (): Promise<Tag[]> => req("/api/tags"),
  createTag: (t: { name: string; color?: string; category?: string }): Promise<Tag> =>
    req("/api/tags", { method: "POST", body: JSON.stringify(t) }),
  updateTag: (id: number, patch: { name?: string; color?: string }) =>
    req(`/api/tags/${id}`, { method: "PATCH", body: JSON.stringify(patch) }),
  deleteTag: (id: number) => req(`/api/tags/${id}`, { method: "DELETE" }),
};
