import Toastify from 'toastify-js';
import 'toastify-js/src/toastify.css';

function showToast(message, type = 'info') {
  let backgroundColor;
  switch (type) {
    case 'success':
      backgroundColor = 'linear-gradient(to right, #00b09b, #96c93d)';
      break;
    case 'error':
      backgroundColor = 'linear-gradient(to right, #ff5f6d, #ffc371)';
      break;
    case 'warning':
      backgroundColor = 'linear-gradient(to right, #ffafbd, #ffc371)';
      break;
    default:
      backgroundColor = 'linear-gradient(to right, #007bff, #0056b3)';
  }

  Toastify({
    text: message,
    duration: 3000,
    close: true,
    gravity: 'top', // `top` or `bottom`
    position: 'right', // `left`, `center` or `right`
    stopOnFocus: true, // Prevents dismissing of toast on hover
    style: {
      background: backgroundColor,
    },
    onClick: function(){}
  }).showToast();
}

export default showToast;
