"use strict";
'use client';
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = QuickActionLibrary;
const tslib_1 = require("tslib");
const react_1 = require("react");
const library_create_ticket_1 = tslib_1.__importDefault(require("./library-create-ticket"));
const modal_return_book_1 = tslib_1.__importDefault(require("./library-return-ticket/modal-return-book"));
const __1 = require("../../../..");
const react_2 = tslib_1.__importDefault(require("react"));
const constants_1 = require("./constants");
const constant_1 = require("../../constant");
const alert_1 = tslib_1.__importDefault(require("./alert"));
function QuickActionLibrary() {
    var _a, _b;
    const [showModalBorrow, setShowModalBorrow] = (0, react_1.useState)(false);
    const [showModalReturn, setShowModalReturn] = (0, react_1.useState)(false);
    const currentYear = (0, __1.PHXGetCurrentYearWithTermV3)();
    const currentSchoolYearId = (_b = (_a = currentYear === null || currentYear === void 0 ? void 0 : currentYear.current_school_year) === null || _a === void 0 ? void 0 : _a.schoolYear) === null || _b === void 0 ? void 0 : _b.id;
    const [educationalRouteData, setEducationalRouteData] = (0, react_1.useState)({
        educationalCodes: [],
        route: '',
    });
    (0, __1.useMainwrapV4EventBus)(constants_1.KEY_MODULE_CODE_LIBRARY, (payload) => {
        switch (payload.code) {
            case constants_1.QUICK_ACTION_LIBRARY.LIBRARY_TIEU_HOC_BORROW_TICKET_RETURN:
                setShowModalReturn(true);
                setEducationalRouteData({
                    educationalCodes: [constant_1.TIEU_HOC_CODE],
                    route: constants_1.PARENT_ROUTE_LIBRARY.TIEU_HOC,
                });
                break;
            case constants_1.QUICK_ACTION_LIBRARY.LIBRARY_TIEU_HOC_BORROW_TICKET_CREATE:
                setShowModalBorrow(true);
                setEducationalRouteData({
                    educationalCodes: [constant_1.TIEU_HOC_CODE],
                    route: constants_1.PARENT_ROUTE_LIBRARY.TIEU_HOC,
                });
                break;
            case constants_1.QUICK_ACTION_LIBRARY.LIBRARY_TRUNG_HOC_BORROW_TICKET_CREATE:
                setShowModalBorrow(true);
                setEducationalRouteData({
                    educationalCodes: [constant_1.THCS_CODE, constant_1.THPT_CODE],
                    route: constants_1.PARENT_ROUTE_LIBRARY.TRUNG_HOC,
                });
                break;
            case constants_1.QUICK_ACTION_LIBRARY.LIBRARY_TRUNG_HOC_BORROW_TICKET_RETURN:
                setShowModalReturn(true);
                setEducationalRouteData({
                    educationalCodes: [constant_1.THCS_CODE, constant_1.THPT_CODE],
                    route: constants_1.PARENT_ROUTE_LIBRARY.TRUNG_HOC,
                });
                break;
        }
    });
    return (react_2.default.createElement(react_2.default.Fragment, null,
        react_2.default.createElement(alert_1.default, null),
        react_2.default.createElement(library_create_ticket_1.default, { currentSchoolYearId: currentSchoolYearId, educationalCodes: educationalRouteData.educationalCodes, onHide: () => {
                setShowModalBorrow(false);
            }, show: showModalBorrow }),
        react_2.default.createElement(modal_return_book_1.default, { educationalCodes: educationalRouteData.educationalCodes, route: educationalRouteData.route, setShow: setShowModalReturn, show: showModalReturn })));
}
//# sourceMappingURL=index.js.map