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

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

export interface ShortsTemplateConfig {
  show_intro: boolean;
  intro_text: string;
  intro_duration_secs: number;
  show_outro: boolean;
  outro_text: string;
  outro_duration_secs: number;
  accent_color: string;
  font_family: string;
}

export type ShortsTemplateUpdate = ShortsTemplateConfig;

// ── API functions ────────────────────────────────────────────────────────────

export function fetchShortsTemplate(
  creatorId: string,
): Promise<ShortsTemplateConfig> {
  return request<ShortsTemplateConfig>(
    `${BASE}/admin/creators/${encodeURIComponent(creatorId)}/shorts-template`,
  );
}

export function updateShortsTemplate(
  creatorId: string,
  config: ShortsTemplateUpdate,
): Promise<ShortsTemplateConfig> {
  return request<ShortsTemplateConfig>(
    `${BASE}/admin/creators/${encodeURIComponent(creatorId)}/shorts-template`,
    {
      method: "PUT",
      body: JSON.stringify(config),
    },
  );
}
