@shopgate/engage
Version:
Shopgate's ENGAGE library.
77 lines (76 loc) • 2.44 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import I18n from '@shopgate/pwa-common/components/I18n';
import { i18n } from '@shopgate/engage/core';
import { Card } from '@shopgate/engage/components';
import { getTranslatedOrderStatus } from "../../helpers";
import { tableHeader, tableRow } from "./OrderHistoryTable.style";
/**
* The Order History Table Row component
* @param {Object} props props
* @returns {JSX}
*/
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export const TableRow = props => /*#__PURE__*/_jsxs("tr", {
className: tableRow,
onClick: props.openDetails,
children: [/*#__PURE__*/_jsxs("td", {
children: [/*#__PURE__*/_jsx(I18n.Date, {
timestamp: new Date(props.submitDate).getTime(),
format: "short"
}), "\xA0", /*#__PURE__*/_jsx(I18n.Time, {
timestamp: new Date(props.submitDate).getTime(),
format: "short"
})]
}), /*#__PURE__*/_jsx("td", {
children: props.orderNumber
}), /*#__PURE__*/_jsx("td", {
children: getTranslatedOrderStatus(props.status)
}), /*#__PURE__*/_jsx("td", {
align: "right",
children: /*#__PURE__*/_jsx(I18n.Number, {
number: props.lineItemCount,
fractions: 0
})
}), /*#__PURE__*/_jsx("td", {
align: "right",
children: /*#__PURE__*/_jsx(I18n.Price, {
currency: props.currencyCode,
price: props.total
})
})]
}, props.orderNumber);
/**
* The Order History Table component
* @param {Object} props props
* @returns {JSX}
*/
export const Table = ({
children
}) => /*#__PURE__*/_jsx(Card, {
children: /*#__PURE__*/_jsxs("table", {
children: [/*#__PURE__*/_jsx("thead", {
children: /*#__PURE__*/_jsxs("tr", {
className: tableHeader,
children: [/*#__PURE__*/_jsx("th", {
align: "left",
children: i18n.text('orders.header.date')
}), /*#__PURE__*/_jsx("th", {
align: "left",
children: i18n.text('orders.header.orderNumber')
}), /*#__PURE__*/_jsx("th", {
align: "left",
children: i18n.text('orders.header.status')
}), /*#__PURE__*/_jsx("th", {
align: "right",
children: i18n.text('orders.header.lineItemCount')
}), /*#__PURE__*/_jsx("th", {
align: "right",
children: i18n.text('orders.header.total')
})]
})
}), /*#__PURE__*/_jsx("tbody", {
children: children
})]
})
});