import api from '@/core/api/axios';

export const wbsService = {
  upload: (projectId: number, file: File, effectiveDate: string) => {
    const formData = new FormData();
    formData.append('file', file);
    formData.append('effectiveDate', effectiveDate);
    return api.post(`/api/wtm/projects/${projectId}/wbs/upload`, formData, { headers: { 'Content-Type': 'multipart/form-data' } });
  },
  getVersions: (projectId: number) => api.get(`/api/wtm/projects/${projectId}/wbs/versions`),
  getVersionNodes: (projectId: number, version: number) => api.get(`/api/wtm/projects/${projectId}/wbs/versions/${version}`),
  activateVersion: (projectId: number, version: number) => api.post(`/api/wtm/projects/${projectId}/wbs/versions/${version}/activate`),
  getCanonicalWbs: (projectId: number) => api.get(`/api/wtm/projects/${projectId}/canonical-wbs`),
  compareVersions: (projectId: number, v1: number, v2: number) => api.get(`/api/wtm/projects/${projectId}/wbs/compare`, { params: { v1, v2 } }),
};
