"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ReservationRowModal;
const hooks_1 = require("../../hooks/index.js");
const dayjs_1 = __importDefault(require("dayjs"));
const react_1 = __importDefault(require("react"));
const react_i18next_1 = require("react-i18next");
const Translation_1 = require("translations/Translation");
const Currency_1 = __importDefault(require("../../components/generic/Currency"));
const Headline_1 = __importDefault(require("../../components/generic/Headline"));
const Icon_1 = __importStar(require("../../components/generic/Icon/Icon"));
const LineBreak_1 = __importDefault(require("../../components/generic/LineBreak"));
const SimpleModal_1 = __importStar(require("../../components/generic/modal/SimpleModal"));
const Text_1 = __importStar(require("../../components/generic/Text"));
const ImageGallerySlider_1 = __importDefault(require("../../components/steps/room/ImageGallerySlider"));
const Color_1 = require("../../util/Color");
const StringHelper_1 = __importDefault(require("../../util/StringHelper"));
function ReservationRowModal(props) {
    var _a, _b, _c, _d, _e, _f;
    const { hotel } = (0, hooks_1.useCurrentHotel)();
    const { reservation } = props;
    const { t } = (0, react_i18next_1.useTranslation)();
    const images = reservation.images && reservation.images.length ? reservation.images : (_a = props.images) !== null && _a !== void 0 ? _a : [];
    let adultsAndChildren = StringHelper_1.default.pluralWithDictAndCount(reservation.guestCounts.adults, Translation_1.Translation.Step.Date.Adult, t);
    if (reservation.guestCounts.children) {
        adultsAndChildren += ', ' + StringHelper_1.default.pluralWithDictAndCount(reservation.guestCounts.children, Translation_1.Translation.Step.Date.Child, t);
    }
    const nightKeys = Object.keys(reservation.nights);
    const firstNight = (0, dayjs_1.default)(nightKeys[0]);
    const lastNight = (0, dayjs_1.default)(nightKeys[nightKeys.length - 1]).add(1, 'day');
    const guaranteePolicy = reservation.guaranteePolicyLongDescription || '';
    const cancelPolicy = reservation.cancellationPolicyLongDescription || '';
    const roomName = reservation.roomType ? reservation.roomType : (_b = hotel === null || hotel === void 0 ? void 0 : hotel.rooms[reservation.roomCode]) === null || _b === void 0 ? void 0 : _b.name;
    return (react_1.default.createElement(SimpleModal_1.default, { open: props.open, onClose: props.onClose, title: `Reservation #${props.reservation.reservationNumber}`, size: SimpleModal_1.SimpleModalSize.Small },
        react_1.default.createElement(react_1.default.Fragment, null,
            react_1.default.createElement("div", { style: { height: '300px' } },
                react_1.default.createElement(ImageGallerySlider_1.default, { images: images })),
            react_1.default.createElement("div", { className: "u-marg-heavy u-marg@m-" },
                react_1.default.createElement("div", { className: "u-marg-bottom" },
                    react_1.default.createElement(Headline_1.default, { size: "large", bold: true }, roomName),
                    react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small }, reservation.rate)),
                react_1.default.createElement("ul", null,
                    react_1.default.createElement("li", { className: "u-flex justify-content-start u-marg-bottom--light" },
                        react_1.default.createElement(Icon_1.default, { color: Color_1.Color.Grey, icon: Icon_1.IconType.Person }),
                        react_1.default.createElement("div", { className: "u-marg-left--light" },
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                                reservation.guest.firstName,
                                " ",
                                reservation.guest.lastName,
                                " ",
                                react_1.default.createElement("span", { style: { color: Color_1.Color.DarkGrey } },
                                    "- ",
                                    adultsAndChildren)))),
                    react_1.default.createElement("li", { className: "u-flex justify-content-start u-marg-bottom--light" },
                        react_1.default.createElement(Icon_1.default, { icon: Icon_1.IconType.Email, color: Color_1.Color.Grey }),
                        react_1.default.createElement("div", { className: "u-marg-left--light" },
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small }, reservation.guest.email))),
                    react_1.default.createElement("li", { className: "u-flex justify-content-start u-marg-bottom--light" },
                        react_1.default.createElement(Icon_1.default, { icon: Icon_1.IconType.Calendar, color: Color_1.Color.Grey }),
                        react_1.default.createElement("div", { className: "u-marg-left--light" },
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small }, firstNight.format('dddd, MMM D, YYYY')),
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small }, lastNight.format('dddd, MMM D, YYYY')))),
                    react_1.default.createElement("li", { className: "u-flex justify-content-start" },
                        react_1.default.createElement(Icon_1.default, { icon: Icon_1.IconType.CreditCard, color: Color_1.Color.Grey }),
                        react_1.default.createElement("div", { className: "u-marg-left--light" },
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                                "\u2022\u2022\u2022\u2022 \u2022\u2022\u2022\u2022 \u2022\u2022\u2022\u2022 ", (_d = (_c = reservation.paymentCard) === null || _c === void 0 ? void 0 : _c.last4) !== null && _d !== void 0 ? _d : 'N/A',
                                ' ',
                                react_1.default.createElement("span", { style: { color: Color_1.Color.DarkGrey } },
                                    "(", (_f = (_e = reservation.paymentCard) === null || _e === void 0 ? void 0 : _e.type) !== null && _f !== void 0 ? _f : 'N/A',
                                    ")"))))),
                react_1.default.createElement(LineBreak_1.default, null),
                nightKeys.map((night) => {
                    const currentDay = (0, dayjs_1.default)(night);
                    const currentDayFormatted = currentDay.format('dddd, MMM DD, YYYY');
                    return (react_1.default.createElement("div", { className: "u-flex u-marg-bottom", key: reservation.reservationNumber },
                        react_1.default.createElement(Text_1.default, null, currentDayFormatted),
                        react_1.default.createElement(Text_1.default, { color: Color_1.Color.DarkGrey },
                            react_1.default.createElement(Currency_1.default, null, reservation.nights[night].total))));
                }),
                react_1.default.createElement("div", { className: "u-flex" },
                    react_1.default.createElement(Text_1.default, null, lastNight.format('dddd, MMM DD, YYYY')),
                    react_1.default.createElement(Text_1.default, { color: Color_1.Color.Success }, t(Translation_1.Translation.Misc.CheckOut))),
                react_1.default.createElement(LineBreak_1.default, null),
                react_1.default.createElement("div", null,
                    guaranteePolicy && (react_1.default.createElement("div", { className: "u-marg-bottom--heavy" },
                        react_1.default.createElement("div", { className: "u-marg-bottom--light" },
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                                react_1.default.createElement("strong", null, t(Translation_1.Translation.Misc.GuaranteePolicy)))),
                        react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                            react_1.default.createElement("span", { className: "u-clear-font-weight", dangerouslySetInnerHTML: { __html: guaranteePolicy } })))),
                    react_1.default.createElement("div", { className: "u-marg-bottom--heavy" },
                        react_1.default.createElement("div", { className: "u-marg-bottom--light" },
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                                react_1.default.createElement("strong", null, t(Translation_1.Translation.Misc.CancellationPolicy)))),
                        react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                            react_1.default.createElement("span", { className: "u-clear-font-weight", dangerouslySetInnerHTML: { __html: cancelPolicy } }))))))));
}
//# sourceMappingURL=ReservationRowModal.js.map