import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { getBackgroundColor, getElements } from '../utils/helperFunctions';
import OrderPayments from '../OrderPayments';
// styles
import { OrderDetailsWrapper, OrderTimeBlock, QueuePosBlock, OrderTypeBlock, OrderIdBlock, } from './style';
// translation
import { useTranslation } from 'react-i18next';
import { addTimezone, getTime } from '../utils/dates';
const OrderDetails = (props) => {
    const { queuePos, lines, lastChanged, orderType, payments, orderId, kdsDeviceConfigs, } = props;
    const { t } = useTranslation();
    const getOrderTypeName = () => {
        // console.log('getOrderTypeName: ', {
        //   orderType,
        //   name: orderType.replaceAll('_', ' '),
        // });
        switch (orderType) {
            case 'TAKE_AWAY':
                return t('OS.KDS.Card.OrderType.SelfPickUp');
            case 'DELIVERY':
                return t('OS.KDS.Card.OrderType.Delivery');
            case 'DINE_IN':
                return t('OS.KDS.Card.OrderType.DineIn');
            default:
                return orderType.replaceAll('_', ' ');
        }
    };
    const { toDone, allDone, toPrepare, toConfirm } = getElements(lines, kdsDeviceConfigs && kdsDeviceConfigs.KDS_STAGE_DONE
        ? kdsDeviceConfigs.KDS_STAGE_DONE
        : '');
    const formattedLastChange = getTime(addTimezone(lastChanged));
    return (_jsxs(_Fragment, { children: [_jsxs(OrderDetailsWrapper, { children: [_jsxs(QueuePosBlock, { color: getBackgroundColor(allDone, toDone, toConfirm, toPrepare), children: ["No. ", ` `, queuePos] }), _jsx(OrderTimeBlock, { children: formattedLastChange }), _jsxs(OrderTypeBlock, { children: [getOrderTypeName(), " "] }), _jsx(OrderPayments, { payments: payments })] }), _jsxs(OrderIdBlock, { children: [_jsx("strong", { children: "ID:" }), " ", orderId] })] }));
};
export default OrderDetails;
//# sourceMappingURL=index.js.map