import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { useState, useEffect } from 'react';
import CardHeader from '../CardHeader';
import OrderDetails from '../OrderDetails';
import OrderProductsList from '../OrderProductsList';
import UserInformation from '../UserInformation';
import { ContentWrapper, KDSCardWrapper, QueuePosDiv } from './style';
import { getBackgroundColor, getElements } from '../utils/helperFunctions';
import ButtonClose from '../Buttons/ButtonClose';
import ButtonsContainer from '../ButtonsContainer';
const KDSCard = (props) => {
    const { orderType, lastChanged, bucket, orderId, payments, due, extra, deliveryAddress, comments, users, venueConfig, callOrderApi, authProvider, verifiedTime, kdsDeviceConfigs, viewMode = "1" } = props;
    const { toDone, allDone, toPrepare, toConfirm } = getElements(bucket.lines, kdsDeviceConfigs && kdsDeviceConfigs.KDS_STAGE_DONE
        ? kdsDeviceConfigs.KDS_STAGE_DONE
        : '');
    const [isZoomIn, setIsZoomIn] = useState(false);
    useEffect(() => {
        if (isZoomIn) {
            document.body.style.overflow = 'hidden';
        }
        else {
            document.body.style.overflow = 'auto';
        }
    }, [isZoomIn]);
    // viewMode === '1' - standard view
    // viewMode === '2' - minimal view, only queueNo & buttons
    return (_jsxs(KDSCardWrapper, { viewMode: viewMode, isZoomIN: isZoomIn, children: [isZoomIn && _jsx(ButtonClose, { setIsZoomIn: setIsZoomIn }), viewMode !== "2" && (_jsxs(_Fragment, { children: [_jsx(CardHeader, { verifiedTime: verifiedTime, orderType: orderType, due: due, venueConfig: venueConfig }), _jsx(OrderDetails, { queuePos: bucket.queuePos, lines: bucket.lines, lastChanged: lastChanged, orderType: orderType, payments: payments, orderId: orderId, kdsDeviceConfigs: kdsDeviceConfigs })] })), _jsxs(ContentWrapper, { isZoomIn: isZoomIn, viewMode: viewMode, color: getBackgroundColor(allDone, toDone, toConfirm, toPrepare), children: [viewMode !== "2" && (_jsxs(_Fragment, { children: [_jsx(OrderProductsList, { lines: bucket.lines, orderId: orderId, currency: venueConfig.currency, isZoomIN: isZoomIn, kdsDeviceConfigs: kdsDeviceConfigs }), _jsx(UserInformation, { extra: extra, deliveryAddress: deliveryAddress, comments: comments, users: users, kdsLayout: "" })] })), viewMode === "2" && (_jsxs(QueuePosDiv, { color: '#ddd', children: ["#", bucket.queuePos] })), _jsx(ButtonsContainer, { callOrderApi: callOrderApi, setIsZoomIn: setIsZoomIn, isZoomIn: isZoomIn, lines: bucket.lines, orderId: orderId, authProvider: authProvider, kdsDeviceConfigs: kdsDeviceConfigs, viewMode: viewMode })] })] }));
};
export default KDSCard;
//# sourceMappingURL=index.js.map