import { get, post, patch } from './client.js';

export async function fetchOccupations(params = {}) {
  const query = new URLSearchParams(params).toString();
  return get(query ? `/api/occupation?${query}` : '/api/occupation');
}

export async function fetchOccupation(id) {
  return get(`/api/occupation/${id}`);
}

export async function createOccupation(data) {
  const payload = {
    OccCode: data.OccCode,
    OccText: data.OccText,
    Description: data.Description,
  };
  return post('/api/occupation', payload);
}

export async function updateOccupation(id, data) {
  const payload = {
    OccCode: data.OccCode,
    OccText: data.OccText,
    Description: data.Description,
  };
  return patch(`/api/occupation/${id}`, payload);
}
