import * as React from "react"; import { Helmet } from "react-helmet"; import { formatRoute } from "react-router-named-routes"; import ScrollToTopOnMount from "../../utility/ScrollToTop"; import { Tabs, Tab } from "@joincivil/components"; import { AccountProfile } from "./AccountProfile"; import { AccountPayments } from "./AccountPayments"; import { AccountTransactions } from "./AccountTransactions"; import { AccountTitleText, ProfileTabText, PaymentTabText, TransactionsTabText } from "./AccountTextComponents"; import { UserManagementPageLayout, UserManagementTabNav, UserManagementTabs } from "../UserManagement"; export interface AccountParams { activeTab?: "profile" | "payments" | "transactions"; } const TABS = ["profile", "payments", "transactions"]; export interface AccountProps { userAccount?: string; history: any; match: any; } const AccountPage: React.FunctionComponent = props => { // Load tab from path: const [activeTabIndex, setActiveTabIndex] = React.useState(0); React.useEffect(() => { const activeTab = props.match.params.activeTab || "profile"; if (TABS[activeTabIndex] !== activeTab) { setActiveTabIndex(TABS.indexOf(activeTab)); } }, [props.match.params.activeTab]); return ( <> }> { props.history.push(formatRoute(props.match.path, { activeTab: TABS[tab] })); }} flex={true} > }> }> }> ); }; export default AccountPage;