import { apiRequest } from '@/shared/api/httpClient';
import { ApiListResponse } from '@/shared/types/api';
import { FrameEntryDto, FrameEntryMutationDto } from '@/shared/types/frame';

const FRAME_ENTRIES_PATH = '/frame_entries';

export function listFrameEntries(): Promise<ApiListResponse<FrameEntryDto>> {
  return apiRequest<ApiListResponse<FrameEntryDto>>(FRAME_ENTRIES_PATH);
}

export function createFrameEntry(request: FrameEntryMutationDto): Promise<FrameEntryDto> {
  return apiRequest<FrameEntryDto>(FRAME_ENTRIES_PATH, {
    method: 'POST',
    body: { data: request },
  });
}

export function updateFrameEntry(id: string, request: FrameEntryMutationDto): Promise<FrameEntryDto> {
  return apiRequest<FrameEntryDto>(`${FRAME_ENTRIES_PATH}/${id}`, {
    method: 'PUT',
    body: { data: request },
  });
}

export function deleteFrameEntry(id: string): Promise<void> {
  return apiRequest<void>(`${FRAME_ENTRIES_PATH}/${id}`, {
    method: 'DELETE',
  });
}
