import Flash from './flash';

export default class Milestone {
  constructor() {
    this.bindTabsSwitching();

    // Load merge request tab if it is active
    // merge request tab is active based on different conditions in the backend
    this.loadTab($('.js-milestone-tabs .active a'));

    this.loadInitialTab();
  }

  bindTabsSwitching() {
    return $('a[data-toggle="tab"]').on('show.bs.tab', (e) => {
      const $target = $(e.target);

      location.hash = $target.attr('href');
      this.loadTab($target);
    });
  }
  // eslint-disable-next-line class-methods-use-this
  loadInitialTab() {
    const $target = $(`.js-milestone-tabs a[href="${location.hash}"]`);

    if ($target.length) {
      $target.tab('show');
    }
  }
  // eslint-disable-next-line class-methods-use-this
  loadTab($target) {
    const endpoint = $target.data('endpoint');
    const tabElId = $target.attr('href');

    if (endpoint && !$target.hasClass('is-loaded')) {
      $.ajax({
        url: endpoint,
        dataType: 'JSON',
      })
      .fail(() => new Flash('Error loading milestone tab'))
      .done((data) => {
        $(tabElId).html(data.html);
        $target.addClass('is-loaded');
      });
    }
  }
}

@@ -1,16 +1,61 @@
 import 
-F
+axios from './lib/utils/axios_utils';%0Aimport f
 lash fro
@@ -1009,159 +1009,60 @@
     
-$.ajax(%7B%0A        url: endpoint,%0A        dataType: 'JSON',%0A      %7D)%0A      .fail(() =%3E new Flash('Error loading milestone tab'))%0A      .done((
+axios.get(endpoint)%0A        .then((%7B 
 data
+ %7D
 ) =%3E %7B%0A
+  
     
@@ -1097,24 +1097,26 @@
 l);%0A        
+  
 $target.addC
@@ -1136,25 +1136,86 @@
 ed');%0A      
+ 
-%7D
+ %7D)%0A        .catch(() =%3E flash('Error loading milestone tab')
 );%0A    %7D%0A  %7D

Converted milestone.js to axios