import api from './api';
import type {
  CollaborationRequest,
  CreateCollaborationRequest,
  CollaborationResponse,
} from '../types/collaboration';

export const collaborationService = {
  async getBusinessCollaborations(): Promise<CollaborationRequest[]> {
    const response = await api.get<CollaborationRequest[]>('/api/businesses/collaborations/');
    return response.data;
  },

  async sendCollaborationRequest(data: CreateCollaborationRequest): Promise<CollaborationRequest> {
    const response = await api.post<CollaborationRequest>('/api/businesses/collaborations/', data);
    return response.data;
  },

  async getInfluencerCollaborations(): Promise<CollaborationRequest[]> {
    const response = await api.get<CollaborationRequest[]>('/api/influencers/collaborations/');
    return response.data;
  },

  async respondToCollaboration(id: number, data: CollaborationResponse): Promise<CollaborationRequest> {
    const response = await api.patch<CollaborationRequest>(`/api/influencers/collaborations/${id}/respond/`, data);
    return response.data;
  },
};
