"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FileUploadExample = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _FilePicker = require("../components/FilePicker");
var _Padder = require("../components/Padder");
var _Button = require("../components/Button");
var _Dialog = require("../components/Dialog");
var FileUploadExample = function FileUploadExample(_ref) {
  var fileMessage = _ref.fileMessage;
  var _useState = (0, _react.useState)(),
    _useState2 = (0, _slicedToArray2.default)(_useState, 2),
    files = _useState2[0],
    setFiles = _useState2[1];
  var _useState3 = (0, _react.useState)(false),
    _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
    dialogOpen = _useState4[0],
    setDialogOpen = _useState4[1];
  function submit() {
    console.log(files);
    var formData = new FormData();
    formData.append('avatar', files[0]);

    // Post form data.
  }

  return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Dialog.Dialog, {
    content: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_FilePicker.FilePicker, {
      setFiles: setFiles,
      fileMessage: files ? files[0].name : null,
      isFullWidth: true
    })),
    open: dialogOpen,
    close: function close() {
      setDialogOpen(false);
      setFiles();
    },
    title: "Upload file",
    confirmMessage: "upload"
  }), /*#__PURE__*/_react.default.createElement(_Button.Button, {
    onClick: function onClick() {
      return setDialogOpen(true);
    },
    appearance: "primary"
  }, "Upload file"));
};
exports.FileUploadExample = FileUploadExample;