import { toast } from 'react-toastify';

// Custom message component
const LoginMessage = () => {
  const handleClick = () => {
    const currentUrl = window.location.href;
    console.log(currentUrl);
    const redirect = encodeURIComponent(currentUrl);
    console.log('redirect', redirect);
    const newUrl = location.origin + '/user/login/?redirect=' + redirect;
    window.open(newUrl, '_self');
  };

  return (
    <div className='msg-container' onClick={handleClick} style={{ cursor: 'pointer' }}>
      <p className='msg-title'>Please login</p>
      <p className='msg-description'>Click here to go to the login page.</p>
    </div>
  );
};

export const toastLogin = () => {
  toast.info(<LoginMessage />);
};
