"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getModalActionConfig = void 0;
var _services = require("@mirai/services");
var _Booking = require("./Booking.FormCancel");
var _Booking2 = require("./Booking.FormEdit");
var _Booking3 = require("./Booking.FormEditBoard");
var _Booking4 = require("./Booking.FormEditDate");
var _Booking5 = require("./Booking.FormEditOccupation");
var _Booking6 = require("./Booking.FormResend");
var _Booking7 = require("../Booking.constants");
var _Booking8 = require("../Booking.l10n");
var style = _interopRequireWildcard(require("../Booking.module.css"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
const {
  CANCEL,
  EDIT,
  EDIT_BOARD,
  EDIT_BOARD_CONFIRM,
  EDIT_DATE,
  EDIT_OCCUPATION,
  EDIT_OCCUPATION_CONFIRM,
  RESEND,
  SHOW_CALENDAR
} = _Booking7.ACTION;
const ACTION_VALUES = Object.values(_Booking7.ACTION);
const DEFAULT_ACTION = RESEND;
const ACTION_CONFIG = {
  [CANCEL]: {
    Form: _Booking.FormCancel,
    editLayout: false,
    fit: false,
    submitL10N: _Booking8.L10N.ACTION_CANCEL,
    successL10N: _Booking8.L10N.NOTIFICATION_CANCEL_BOOKING_SUCCESS,
    titleL10N: _Booking8.L10N.ACTION_CANCEL_BOOKING,
    state: _Booking7.STATE.CANCELLED,
    request: _ref => {
      let {
        form,
        id,
        idHotel,
        pinCode,
        token
      } = _ref;
      return _services.ServiceBooking.cancel(_objectSpread({
        id,
        idHotel,
        pinCode,
        token
      }, form));
    }
  },
  [EDIT]: {
    Form: _Booking2.FormEdit,
    editLayout: false,
    fit: false,
    submitL10N: _Booking8.L10N.ACTION_POSTPONE,
    successL10N: _Booking8.L10N.NOTIFICATION_EDIT_BOOKING_SUCCESS,
    titleL10N: _Booking8.L10N.ACTION_EDIT_BOOKING,
    state: _Booking7.STATE.POSTPONED,
    request: _ref2 => {
      let {
        form,
        id,
        idHotel,
        pinCode,
        token
      } = _ref2;
      return _services.ServiceBooking.postpone(_objectSpread({
        id,
        idHotel,
        pinCode,
        token
      }, form));
    }
  },
  [EDIT_DATE]: {
    Form: _Booking4.FormEditDate,
    backAction: SHOW_CALENDAR,
    className: style.modalConfirmDialog,
    editLayout: true,
    fit: true,
    submitL10N: _Booking8.L10N.ACTION_CONFIRM,
    successL10N: _Booking8.L10N.NOTIFICATION_EDIT_DATE_SUCCESS,
    titleL10N: _Booking8.L10N.ACTION_EDIT_DATE,
    warningOn404: true,
    getFormProps: _ref3 => {
      let {
        responseCalendar
      } = _ref3;
      return {
        responseCalendar
      };
    },
    request: _ref4 => {
      let {
        form,
        id
      } = _ref4;
      return _services.ServiceBooking.modification.date.confirm(_objectSpread({
        id
      }, form));
    }
  },
  [EDIT_BOARD_CONFIRM]: {
    Form: _Booking3.FormEditBoard,
    backAction: EDIT_BOARD,
    className: style.modalConfirmDialog,
    editLayout: true,
    fit: true,
    submitL10N: _Booking8.L10N.ACTION_CONFIRM,
    successL10N: _Booking8.L10N.NOTIFICATION_EDIT_BOARD_SUCCESS,
    titleL10N: _Booking8.L10N.ACTION_EDIT_BOARD,
    getFormProps: _ref5 => {
      let {
        responseBoard
      } = _ref5;
      return {
        responseBoard
      };
    },
    request: _ref6 => {
      let {
        form,
        id
      } = _ref6;
      return _services.ServiceBooking.modification.board.confirm(_objectSpread({
        id
      }, form));
    }
  },
  [EDIT_OCCUPATION_CONFIRM]: {
    Form: _Booking5.FormEditOccupation,
    backAction: EDIT_OCCUPATION,
    className: style.modalConfirmDialog,
    editLayout: true,
    fit: true,
    submitL10N: _Booking8.L10N.ACTION_CONFIRM,
    successL10N: _Booking8.L10N.NOTIFICATION_EDIT_OCCUPATION_SUCCESS,
    titleL10N: _Booking8.L10N.ACTION_EDIT_OCCUPATION,
    getFormProps: _ref7 => {
      let {
        responseOccupation
      } = _ref7;
      return {
        responseOccupation
      };
    },
    request: _ref8 => {
      let {
        form,
        id
      } = _ref8;
      return _services.ServiceBooking.modification.occupation.confirm(_objectSpread({
        id
      }, form));
    }
  },
  [RESEND]: {
    Form: _Booking6.FormResend,
    disableSubmitOnError: true,
    editLayout: false,
    fit: false,
    submitL10N: _Booking8.L10N.ACTION_SEND,
    successL10N: _Booking8.L10N.NOTIFICATION_EMAIL_SUCCESS,
    titleL10N: _Booking8.L10N.ACTION_RESEND_BOOKING,
    request: _ref9 => {
      let {
        form,
        id,
        idHotel,
        pinCode,
        token
      } = _ref9;
      return _services.ServiceBooking.email(_objectSpread({
        id,
        idHotel,
        pinCode,
        token
      }, form));
    }
  }
};
const getModalActionConfig = action => ACTION_CONFIG[ACTION_VALUES.includes(action) ? action : DEFAULT_ACTION];
exports.getModalActionConfig = getModalActionConfig;
//# sourceMappingURL=Booking.Modal.actions.js.map