window.addEventListener('load', function() {
  $('#searchForm').on('submit', function(e) {
    const searchKeyword = $("#searchText").val();

    if (!searchKeyword) {
      $('#searchText').attr('disabled', 'disabled');
    }

    return true;
  });

  $('.btn-remove').on('click', function(e) {
    e.preventDefault();

    const itemId = $(this).data('id');
    const transport_provider = $(this).data('transport-provider');

    $modal = $('#remove-transport-provider-warning-modal');
    $modal.find('h4.modal-title').text(`Removing name: ${transport_provider}`);
    $modal.find('#removeBtn').data('id', itemId);
  });

  $('#removeBtn').on('click', function(e) {
    e.preventDefault();
    const itemId = $(this).data('id');
    window.__api__.remove(`/transport_provider/remove/${itemId}`, itemId);
  })
});