text: import * as actionTypes from './actionTypes';
  import axiosInstance from "../../axios-orders";
  
  export const addIngredient = (name) => {
      return {
          type: actionTypes.ADD_INGREDIENT,
          ingredientName: name
      }
  };
  
  export const removeIngredient = (name) => {
      return {
          type: actionTypes.REMOVE_INGREDIENT,
          ingredientName: name
      }
  };
  
  export const setIngredients = (ingredients) => {
      return {
          type: actionTypes.SET_INGREDIENTS,
          ingredients: ingredients
      }
  };
  
  export const fetchIngredientsFailed = () => {
      return {
          type: actionTypes.FETCH_INGREDIENTS_FAILED,
      }
  };
  
  export const initIngredients = () => {
      return dispatch => {
          axiosInstance.get('https://react-my-burger-e5a66.firebaseio.com/ingredients.json')
              .then(response => {
                  dispatch(setIngredients(response.data));
              })
              .catch(error => {
                  dispatch(fetchIngredientsFailed());
              });
      }
  };