@shopgate/engage
Version:
Shopgate's ENGAGE library.
77 lines (76 loc) • 2.65 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import I18n from '@shopgate/pwa-common/components/I18n';
import appConfig from '@shopgate/pwa-common/helpers/config';
import { i18n, useRoute } from '@shopgate/engage/core';
import { ResponsiveContainer } from '@shopgate/engage/components';
import OrderHistory from "../../../orders/components/OrderHistory";
import OrderHistoryProvider from "../../../orders/providers/OrderHistoryProvider";
import { Tabs, Tab, TabPanel } from "../../../components/Tabs";
import { tabs, title, tabPanel } from "./Account.style";
import Lists from "../../../favorites/components/Lists";
import connect from "./Account.connector";
import { TabContext } from "../../../components/Tabs/TabContext";
import Profile from "../Profile";
/**
* The Tabs components
* @returns {JSX}
*/
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const Account = ({
historyReplace
}) => {
const {
params: {
tab = 'profile'
}
} = useRoute();
return /*#__PURE__*/_jsxs(TabContext, {
value: tab,
children: [/*#__PURE__*/_jsxs("div", {
className: tabs,
children: [/*#__PURE__*/_jsx(ResponsiveContainer, {
webOnly: true,
breakpoint: ">xs",
children: /*#__PURE__*/_jsx("div", {
className: title,
children: /*#__PURE__*/_jsx(I18n.Text, {
string: "titles.your_account"
})
})
}), /*#__PURE__*/_jsxs(Tabs, {
indicatorColor: "primary",
textColor: "primary",
onChange: (event, newValue) => historyReplace({
pathname: `/account/${newValue}`
}),
"aria-label": "disabled tabs example",
children: [/*#__PURE__*/_jsx(Tab, {
value: "profile",
label: i18n.text('titles.profile')
}), /*#__PURE__*/_jsx(Tab, {
value: "orders",
label: i18n.text('titles.order_history')
}), appConfig.hasFavorites ? /*#__PURE__*/_jsx(Tab, {
value: "wish-list",
label: i18n.text('titles.favorites')
}) : null]
})]
}), /*#__PURE__*/_jsx(TabPanel, {
className: tabPanel,
value: "profile",
children: /*#__PURE__*/_jsx(Profile, {})
}), /*#__PURE__*/_jsx(TabPanel, {
className: tabPanel,
value: "orders",
children: /*#__PURE__*/_jsx(OrderHistoryProvider, {
children: /*#__PURE__*/_jsx(OrderHistory, {})
})
}), appConfig.hasFavorites ? /*#__PURE__*/_jsx(TabPanel, {
className: tabPanel,
value: "wish-list",
children: /*#__PURE__*/_jsx(Lists, {})
}) : null]
});
};
export default connect(Account);