File size: 2,397 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | import { useTranslate } from 'i18n-calypso';
import { LayoutWithGuidedTour as Layout } from 'calypso/a8c-for-agencies/components/layout/layout-with-guided-tour';
import LayoutTop from 'calypso/a8c-for-agencies/components/layout/layout-with-payment-notification';
import MobileSidebarNavigation from 'calypso/a8c-for-agencies/components/sidebar/mobile-sidebar-navigation';
import { A4A_SETTINGS_LINK } from 'calypso/a8c-for-agencies/components/sidebar-menu/lib/constants';
import LayoutBody from 'calypso/layout/hosting-dashboard/body';
import LayoutHeader, { LayoutHeaderTitle as Title } from 'calypso/layout/hosting-dashboard/header';
import LayoutNavigation, {
buildNavItems,
LayoutNavigationItemProps,
LayoutNavigationTabs,
} from 'calypso/layout/hosting-dashboard/nav';
import { useDispatch } from 'calypso/state';
import { recordTracksEvent } from 'calypso/state/analytics/actions';
import AgencyProfile from './agency-profile';
import { SETTINGS_AGENCY_PROFILE_TAB } from './constants';
type Props = {
selectedTab: string;
};
export default function Settings( { selectedTab }: Props ) {
const translate = useTranslate();
const dispatch = useDispatch();
const title = translate( 'Settings' );
// Define here all the Settings tabs
const settingsTabs: { [ key: string ]: LayoutNavigationItemProps } = {
[ SETTINGS_AGENCY_PROFILE_TAB ]: {
key: SETTINGS_AGENCY_PROFILE_TAB,
label: translate( 'Agency Profile' ),
},
};
// Build all the navigation items
const navItems = buildNavItems( {
items: Object.values( settingsTabs ),
selectedKey: selectedTab,
basePath: A4A_SETTINGS_LINK,
onItemClick: () => {
dispatch(
recordTracksEvent( 'calypso_a4a_settings_click', {
status: selectedTab,
} )
);
},
} );
const selectedItemProps = {
selectedText: settingsTabs[ selectedTab ].label,
};
// Content tab switch
let tabContent = null;
switch ( selectedTab ) {
case SETTINGS_AGENCY_PROFILE_TAB:
tabContent = <AgencyProfile />;
break;
}
return (
<Layout title={ title } wide sidebarNavigation={ <MobileSidebarNavigation /> }>
<LayoutTop>
<LayoutHeader>
<Title>{ title }</Title>
</LayoutHeader>
<LayoutNavigation { ...selectedItemProps }>
<LayoutNavigationTabs { ...selectedItemProps } items={ navItems } />
</LayoutNavigation>
</LayoutTop>
<LayoutBody>{ tabContent }</LayoutBody>
</Layout>
);
}
|