import React, { PropTypes } from 'react';

import { genStandardFileName } from '../../utils/filenames';

console.log(genStandardFileName());

import './Main.scss';

const handleDownload = (url) => () => chrome.downloads.download({ url, filename: genStandardFileName() });

export default function Main(props) {
  const {
    url,
    handleRequestClick,
    cardCreated,
  } = props;

  return (
    <div className="main-container">
      <header>
        <h1>kaeru</h1>
      </header>
      <main>
        <p className="message">{cardCreated ? 'card created!' : ''}</p>
        <button tabIndex="-1" className="request-card" onClick={handleRequestClick}>make card</button>
        <button disabled={!cardCreated} className="download-card" onClick={handleDownload(url)}>download!</button>
      </main>
      <footer>
        <p>Made with ❤️ by <a tabIndex="-1" href="https://github.com/mdboop">mdboop</a>.</p>
      </footer>
    </div>
  );
}

Main.propTypes = {
  url: PropTypes.string,
  cardCreated: PropTypes.bool,
  handleRequestClick: PropTypes.func,
};

@@ -102,45 +102,8 @@
 ';%0A%0A
-console.log(genStandardFileName());%0A%0A
 impo
@@ -227,16 +227,76 @@
 me() %7D);
+%0Aconst openTab = (url) =%3E () =%3E chrome.tabs.create(%7B url %7D);
 %0A%0Aexport
@@ -486,16 +486,32 @@
 eru%3C/h1%3E
+%3Csup%3Ealpha%3C/sup%3E
 %0A      %3C
@@ -885,28 +885,26 @@
  %3Ca 
-tabIndex=%22-1%22 href=%22
+onClick=%7BopenTab('
 http
@@ -924,16 +924,40 @@
 m/mdboop
+')%7D tabIndex=%22-1%22 href=%22
 %22%3Emdboop

fix link to github