text: /* eslint-disable no-unused-vars */
  import cogoToast from 'cogo-toast';
  import {
  DELETE_BUS_START,
  DELETE_BUS_SUCCESS,
  DELETE_BUS_ERROR
  } from './actionTypes';
  import AuthService from '../../../../../utils/AuthService';
  import API from '../../../../../utils/API';
  import history from '../../../../../utils/history';
  
  
  const apiStart = () =>({
      type: DELETE_BUS_START,
  });
  
  const apiSuccess = (payload) =>({
      type: DELETE_BUS_SUCCESS,
      payload
  });
  
  const apiError = (error) =>({
      type: DELETE_BUS_ERROR,
      error
  });
  
  const showSuccessMessage = (message) => {
      cogoToast.success(message, { position: 'top-right' });
    };
  
  const showErrorMessage = (message) => {
      cogoToast.error(message, { position: 'top-right' });
    };
  
    export const deleteBus = (id) => async (dispatch) =>{
      dispatch(apiStart());
      try {
        const token = AuthService.getToken();
        const config = {
          headers: {
              'Content-Type': 'application/json',
              Authorization: `Bearer ${token}`,
          },
        };
          const response = await API.delete(`/company/bus/${id}/`, config);
          showSuccessMessage('Bus deleted Successfully');
          dispatch(apiSuccess(id));
          history.push('/viewBusList')
  
      } catch (error) {
          console.log(error);
          showErrorMessage('Error deleting Bus, is linked to schedule you can disable it ');
          dispatch(apiError(error.response));
      }
  }