import { apiClient } from './client';
import type { Engagement, EngagementInput } from './types';

export async function listEngagements(): Promise<Engagement[]> {
  const { data } = await apiClient.get<Engagement[]>('/engagements');
  return data;
}

export async function fetchEngagement(id: number): Promise<Engagement> {
  const { data } = await apiClient.get<Engagement>(`/engagements/${id}`);
  return data;
}

export async function createEngagement(input: EngagementInput): Promise<Engagement> {
  const { data } = await apiClient.post<Engagement>('/engagements', input);
  return data;
}

export async function patchEngagement(
  id: number,
  input: Partial<EngagementInput>,
): Promise<Engagement> {
  const { data } = await apiClient.patch<Engagement>(`/engagements/${id}`, input);
  return data;
}

export async function deleteEngagement(id: number): Promise<void> {
  await apiClient.delete(`/engagements/${id}`);
}
