"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _typeof = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.empty = exports.default = exports.contact = exports.company = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _react = _interopRequireWildcard(require("react"));

var _utils = require("../../../.storybook/utils");

var _uiIcons = require("@teamleader/ui-icons");

var _index = require("../../index");

var _avatar = _interopRequireDefault(require("../../static/data/avatar"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var contactAvatar = _avatar.default[1].image;
var companyAvatar = _avatar.default[2].image;
var emptyAvatar = _avatar.default[3].image;
var contactLineItems = [{
  children: 'Dunder Miflin',
  icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconBuildingSmallOutline, null),
  href: '/companies.php?id=2',
  title: 'Dunder Miflin'
}, {
  children: '+1 257 689 5454',
  icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconPhoneSmallOutline, null),
  onClick: function onClick() {
    return console.log('Clicked on telephone number');
  },
  title: 'Dial +1 257 689 5454'
}, {
  children: 'david.brent@dundermiflin.com',
  icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconMailSmallOutline, null)
}];
var companyLineItems = [{
  children: '+1 257 689 5454',
  icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconPhoneSmallOutline, null),
  onClick: function onClick() {
    return console.log('Clicked on telephone number');
  },
  title: 'Dial +1 257 689 5454'
}, {
  children: 'david.brent@dundermiflin.com',
  icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconMailSmallOutline, null),
  href: 'mailto:david.brent@dundermiflin.com',
  title: 'Mail to david.brent@dundermiflin.com'
}];
var _default = {
  component: _index.Passport,
  title: (0, _utils.addStoryInGroup)(_utils.COMPOSITIONS, 'Passport'),
  parameters: {
    info: {
      propTablesExclude: [_index.Badge, _index.Box]
    }
  }
};
exports.default = _default;

var usePassportState = function usePassportState() {
  var _useState = (0, _react.useState)(false),
      _useState2 = (0, _slicedToArray2.default)(_useState, 2),
      active = _useState2[0],
      setActive = _useState2[1];

  var _useState3 = (0, _react.useState)(undefined),
      _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
      anchorEl = _useState4[0],
      setAnchorEl = _useState4[1];

  var handleSetActiveClick = function handleSetActiveClick(event) {
    setAnchorEl(event.currentTarget);
    setActive(true);
  };

  var handleSetInactiveClick = function handleSetInactiveClick() {
    setActive(false);
  };

  return {
    active: active,
    anchorEl: anchorEl,
    handleButtonClick: handleSetActiveClick,
    handleCloseClick: handleSetInactiveClick
  };
};

var contact = function contact(args) {
  var _usePassportState = usePassportState(),
      active = _usePassportState.active,
      anchorEl = _usePassportState.anchorEl,
      handleButtonClick = _usePassportState.handleButtonClick,
      handleCloseClick = _usePassportState.handleCloseClick;

  return /*#__PURE__*/_react.default.createElement(_index.Box, {
    display: "flex",
    justifyContent: "center"
  }, /*#__PURE__*/_react.default.createElement(_index.Badge, {
    onClick: handleButtonClick,
    icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconBuildingSmallOutline, null),
    inherit: false
  }, "David Brent"), /*#__PURE__*/_react.default.createElement(_index.Passport, (0, _extends2.default)({}, args, {
    active: active,
    anchorEl: anchorEl,
    description: "Regional manager",
    onEscKeyDown: handleCloseClick,
    onOverlayClick: handleCloseClick,
    avatar: {
      imageUrl: contactAvatar,
      fullName: 'David Brent'
    },
    lineItems: contactLineItems,
    title: {
      children: 'David Brent',
      href: 'https://www.teamleader.eu'
    }
  })));
};

exports.contact = contact;

var company = function company(args) {
  var _usePassportState2 = usePassportState(),
      active = _usePassportState2.active,
      anchorEl = _usePassportState2.anchorEl,
      handleButtonClick = _usePassportState2.handleButtonClick,
      handleCloseClick = _usePassportState2.handleCloseClick;

  return /*#__PURE__*/_react.default.createElement(_index.Box, {
    display: "flex",
    justifyContent: "center"
  }, /*#__PURE__*/_react.default.createElement(_index.Badge, {
    onClick: handleButtonClick,
    icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconBuildingSmallOutline, null),
    inherit: false
  }, "Dunder Miflin"), /*#__PURE__*/_react.default.createElement(_index.Passport, (0, _extends2.default)({}, args, {
    active: active,
    anchorEl: anchorEl,
    description: ['1725 Slough Avenue', 'Sranton, PA 18540', 'United Kingdom'],
    onEscKeyDown: handleCloseClick,
    onOverlayClick: handleCloseClick,
    avatar: {
      imageUrl: companyAvatar,
      shape: 'rounded',
      fullName: 'Dunder Miflin'
    },
    lineItems: companyLineItems,
    title: "Dunder Miflin"
  })));
};

exports.company = company;

var empty = function empty(args) {
  var _usePassportState3 = usePassportState(),
      active = _usePassportState3.active,
      anchorEl = _usePassportState3.anchorEl,
      handleButtonClick = _usePassportState3.handleButtonClick,
      handleCloseClick = _usePassportState3.handleCloseClick;

  return /*#__PURE__*/_react.default.createElement(_index.Box, {
    display: "flex",
    justifyContent: "center"
  }, /*#__PURE__*/_react.default.createElement(_index.Badge, {
    onClick: handleButtonClick,
    icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconBuildingSmallOutline, null),
    inherit: false
  }, "No information"), /*#__PURE__*/_react.default.createElement(_index.EmptyPassport, (0, _extends2.default)({}, args, {
    active: active,
    anchorEl: anchorEl,
    link: {
      children: 'Start now',
      href: 'https://www.teamleader.eu'
    },
    description: "It looks like you haven't added any contact information yet.",
    onEscKeyDown: handleCloseClick,
    onOverlayClick: handleCloseClick,
    avatar: {
      imageUrl: emptyAvatar,
      fullName: 'No Information'
    },
    title: "No information to show"
  })));
};

exports.empty = empty;