import Icon from './Icon';
const getUrl = (url, params) => {
  const u = new URL(url);
  Object.entries(params).forEach(([key, value]) => {
    u.searchParams.set(key, value);
  });
  return u.href;
};
export default {
  exposed: [{
    name: 'X',
    icon: <Icon icon="x" />,
    getHref: opts => getUrl('https://twitter.com/intent/tweet', {
      url: opts.shareUrl,
      text: opts.shareHeadline,
      via: 'politico'
    })
  }, {
    name: 'E-Mail',
    icon: <Icon icon="mail" />,
    getHref: opts => {
      const q = new URLSearchParams({
        to: '',
        subject: opts.shareHeadline,
        body: opts.shareUrl
      });
      return `mailto:?${q}`;
    }
  }],
  hidden: [{
    name: 'LinkedIn',
    icon: <Icon icon="linkedin" />,
    getHref: opts => getUrl('https://www.linkedin.com/sharing/share-offsite/', {
      url: opts.shareUrl
    })
  }, {
    name: 'WhatsApp',
    icon: <Icon icon="whatsapp" />,
    getHref: opts => getUrl('https://wa.me/', {
      text: opts.shareUrl
    })
  }, {
    name: 'Reddit',
    icon: <Icon icon="reddit" />,
    getHref: opts => getUrl('http://www.reddit.com/submit', {
      url: opts.shareUrl,
      title: opts.shareHeadline
    })
  }]
};