import apiClient from "./api";

export const roleService = {
  getAll() {
    return apiClient.get("/roles");
  },
  getById(id) {
    return apiClient.get(`/roles/${id}`);
  },
  create(data) {
    return apiClient.post("/roles", data);
  },
  update(id, data) {
    return apiClient.put(`/roles/${id}`, data);
  },
  delete(id) {
    return apiClient.delete(`/roles/${id}`);
  },
};

export const permissionService = {
  getAll() {
    return apiClient.get("/permissions");
  },
  /**
   * Permissions that may be assigned to roles (excludes company.*, project.*).
   * Use for role create/edit forms.
   */
  getRoleAssignable() {
    return apiClient.get("/permissions", { params: { role_assignable: 1 } });
  },
};
