import apiService from '../../src/APIRequestService/APIService'; // Import the apiService instance

const ExcelControlAPI = {
  // Demo template download
  demoDownload: (fileType) =>
    apiService.get(`/api/template/demo/download/${fileType}`),

  // Download CSV
  downloadCSV: (tableName) =>
    apiService.get('/api/template/download-csv', { tableName }),

  // Get all templates
  getAllTemplates: () =>
    apiService.get('/api/template/getalltemplate'),

  // Get template by ID
  getTemplateById: (id) =>
    apiService.get(`/api/template/gettemplatebyid/${id}`),

  // Save a template with file
  saveTemplate: (file, entityName, name) => {
    const formData = new FormData();
    formData.append('file', file);

    return apiService.post(`/api/template/save/${entityName}/${name}`, formData, {
      headers: { 'Content-Type': 'multipart/form-data' },
    });
  },

  // Delete template by ID
  deleteTemplate: (id) =>
    apiService.delete(`/api/template/deletetemplate/${id}`),
};

export default ExcelControlAPI;
