import _slicedToArray from "@babel/runtime/helpers/slicedToArray";

/* eslint-disable no-unused-vars */

/* eslint-disable no-console */
import React, { useState } from 'react';
import { storiesOf } from '@storybook/react';
import Modal from '../../components/Modal';
import Link from '../../components/Link';
import InfoBar from '../../components/InfoBar';
export default function BrowserWarning() {
  var _useState = useState(true),
      _useState2 = _slicedToArray(_useState, 2),
      open = _useState2[0],
      setOpen = _useState2[1];

  var isIE = function isIE() {
    var ua = window.navigator.userAgent; //Check the userAgent property of the window.navigator object

    var msie = ua.indexOf('MSIE '); // IE 10 or older

    var trident = ua.indexOf('Trident/'); //IE 11
    //Remove this line in production and use second line

    return true; //return msie > 0 || trident > 0;
  };

  var toggleModal = function toggleModal() {
    setOpen(!open);
  };

  var submitAndClose = function submitAndClose() {
    setOpen(false);
  };

  if (isIE()) return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("button", {
    onClick: toggleModal
  }, "Manually open warning modal"), /*#__PURE__*/React.createElement(Modal, {
    open: open,
    primaryButtonText: "Continue with current browser",
    onRequestSubmit: submitAndClose,
    modalHeading: "Outdated browser",
    onRequestClose: toggleModal,
    danger: true
  }, /*#__PURE__*/React.createElement("p", {
    className: "wfp--modal-content__text"
  }, "It looks like you are using Internet Explorer 11 or older as your favourite browser. We recommend that you switch to a more modern browser to ensure that you get the best experience out of this application. ", /*#__PURE__*/React.createElement(Link, {
    href: "#"
  }, "Learn more on go.wfp.org."))));
  return null;
}