import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import ButtonKDS from '../Buttons/ButtonKDS';
import { getElements } from '../utils/helperFunctions';
import { ButtonsWrapper } from './style';
import { useTranslation } from 'react-i18next';
const showProcessedButtons = (toDone) => toDone && toDone.length > 0;
const showDeliveredButton = (allDone, toDone) => allDone && allDone.length > 0 && toDone && toDone.length === 0;
const ButtonsContainer = (props) => {
    const { isZoomIn, setIsZoomIn, lines, callOrderApi, orderId, authProvider, } = props;
    const { toDone, allDone, toPrepare, toConfirm } = getElements(lines);
    const { t } = useTranslation();
    const setOrderStatus = async (type, elements) => {
        try {
            const { token } = await authProvider();
            callOrderApi(orderId, type, token, elements);
        }
        catch (error) {
            console.warn(error);
        }
    };
    return (_jsxs(ButtonsWrapper, { children: [toConfirm.length > 0 && (_jsx(ButtonKDS, { text: t('OS.KDS.Card.Button.CancelPreparing'), callOrderApi: () => setOrderStatus('confirm', toConfirm) }, void 0)), toPrepare.length > 0 && (_jsx(ButtonKDS, { text: t('OS.KDS.Card.Button.PrepareAll'), callOrderApi: () => setOrderStatus('prepare', toPrepare) }, void 0)), showProcessedButtons(toDone) && (_jsxs(_Fragment, { children: [_jsx(ButtonKDS, { text: t('OS.KDS.Card.Button.DoneAll'), isIcon: true, callOrderApi: () => setOrderStatus('prepared', toDone) }, void 0), isZoomIn ? (_jsx(ButtonKDS, { type: "white", text: t('OS.KDS.Card.Button.Minimize'), setIsZoomIn: setIsZoomIn, isZoomIn: isZoomIn }, void 0)) : (_jsx(ButtonKDS, { type: "white", isIcon: true, text: t('OS.KDS.Card.Button.Enlarge'), setIsZoomIn: setIsZoomIn, isZoomIn: isZoomIn }, void 0))] }, void 0)), showDeliveredButton(allDone, toDone) && (_jsx(ButtonKDS, { text: t('OS.KDS.Card.Button.Delivered'), type: "large", callOrderApi: () => setOrderStatus('deliver', []) }, void 0))] }, void 0));
};
export default ButtonsContainer;
//# sourceMappingURL=index.js.map