import api from '@/core/api/axios';
const BASE = '/api/wtm/timesheets';
export const timesheetService = {
  getWeekly: (weekStart: string) => api.get(`${BASE}/week`, { params: { weekStart } }),
  saveEntry: (tid: number, entry: unknown) => api.post(`${BASE}/${tid}/entries`, entry),
  saveBatch: (tid: number, entries: unknown[]) => api.put(`${BASE}/${tid}/entries/batch`, entries),
  deleteEntry: (tid: number, eid: number) => api.delete(`${BASE}/${tid}/entries/${eid}`),
  submit: (tid: number) => api.post(`${BASE}/${tid}/submit`),
  getHistory: (p?: Record<string, unknown>) => api.get(`${BASE}/history`, { params: p }),
  uploadExcel: (file: File, weekStart: string) => { const f = new FormData(); f.append('file', file); f.append('weekStart', weekStart); return api.post(`${BASE}/upload`, f, { headers: { 'Content-Type': 'multipart/form-data' } }); },
  downloadTemplate: () => api.get(`${BASE}/upload/template`, { responseType: 'blob' }),
};
