"use strict";

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

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

var _propertyType = _interopRequireDefault(require("../property-type"));

var _withNotice = _interopRequireDefault(require("../../store/with-notice"));

var _designSystem = require("../design-system");

var _actionHeader = _interopRequireDefault(require("../app/action-header"));

var _useResourceNew = _interopRequireDefault(require("../../hooks/use-resource-new"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const New = props => {
  const {
    record: initialRecord,
    resource,
    addNotice,
    action
  } = props;
  const {
    record,
    handleChange,
    handleSubmit
  } = (0, _useResourceNew.default)(initialRecord, resource.id, addNotice);
  return _react.default.createElement(_designSystem.Box, {
    as: "form",
    onSubmit: handleSubmit,
    flex: true,
    flexGrow: 1,
    flexDirection: "column",
    height: 1
  }, _react.default.createElement(_designSystem.DrawerContent, null, (action === null || action === void 0 ? void 0 : action.showInDrawer) ? _react.default.createElement(_actionHeader.default, props) : null, resource.editProperties.map(property => _react.default.createElement(_propertyType.default, {
    key: property.name,
    where: "edit",
    onChange: handleChange,
    property: property,
    resource: resource,
    record: record
  }))), _react.default.createElement(_designSystem.DrawerFooter, null, _react.default.createElement(_designSystem.Button, {
    variant: "primary",
    size: "lg"
  }, "Save")));
};

var _default = (0, _withNotice.default)(New);

exports.default = _default;