phx-react
Version:
PHX REACT
59 lines • 3.1 kB
JavaScript
'use client';
import { useState } from 'react';
import ModalCreateBorrowTicket from './library-create-ticket';
import ModalReturnBook from './library-return-ticket/modal-return-book';
import { PHXGetCurrentYearWithTermV3, useMainwrapV4EventBus } from '../../../..';
import React from 'react';
import { KEY_MODULE_CODE_LIBRARY, PARENT_ROUTE_LIBRARY, QUICK_ACTION_LIBRARY } from './constants';
import { THCS_CODE, THPT_CODE, TIEU_HOC_CODE } from '../../constant';
import AlertLibrary from './alert';
export default function QuickActionLibrary() {
var _a, _b;
const [showModalBorrow, setShowModalBorrow] = useState(false);
const [showModalReturn, setShowModalReturn] = useState(false);
const currentYear = 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] = useState({
educationalCodes: [],
route: '',
});
useMainwrapV4EventBus(KEY_MODULE_CODE_LIBRARY, (payload) => {
switch (payload.code) {
case QUICK_ACTION_LIBRARY.LIBRARY_TIEU_HOC_BORROW_TICKET_RETURN:
setShowModalReturn(true);
setEducationalRouteData({
educationalCodes: [TIEU_HOC_CODE],
route: PARENT_ROUTE_LIBRARY.TIEU_HOC,
});
break;
case QUICK_ACTION_LIBRARY.LIBRARY_TIEU_HOC_BORROW_TICKET_CREATE:
setShowModalBorrow(true);
setEducationalRouteData({
educationalCodes: [TIEU_HOC_CODE],
route: PARENT_ROUTE_LIBRARY.TIEU_HOC,
});
break;
case QUICK_ACTION_LIBRARY.LIBRARY_TRUNG_HOC_BORROW_TICKET_CREATE:
setShowModalBorrow(true);
setEducationalRouteData({
educationalCodes: [THCS_CODE, THPT_CODE],
route: PARENT_ROUTE_LIBRARY.TRUNG_HOC,
});
break;
case QUICK_ACTION_LIBRARY.LIBRARY_TRUNG_HOC_BORROW_TICKET_RETURN:
setShowModalReturn(true);
setEducationalRouteData({
educationalCodes: [THCS_CODE, THPT_CODE],
route: PARENT_ROUTE_LIBRARY.TRUNG_HOC,
});
break;
}
});
return (React.createElement(React.Fragment, null,
React.createElement(AlertLibrary, null),
React.createElement(ModalCreateBorrowTicket, { currentSchoolYearId: currentSchoolYearId, educationalCodes: educationalRouteData.educationalCodes, onHide: () => {
setShowModalBorrow(false);
}, show: showModalBorrow }),
React.createElement(ModalReturnBook, { educationalCodes: educationalRouteData.educationalCodes, route: educationalRouteData.route, setShow: setShowModalReturn, show: showModalReturn })));
}
//# sourceMappingURL=index.js.map