File size: 1,386 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
import { type Callback } from '@automattic/calypso-router';
import PageViewTracker from 'calypso/a8c-for-agencies/components/a4a-page-view-tracker';
import MainSidebar from '../../components/sidebar-menu/main';
import { TAB_ACTIVE_MEMBERS } from './constants';
import TeamAcceptInvite from './primary/team-accept-invite';
import TeamInvite from './primary/team-invite';
import TeamList from './primary/team-list';

export const teamContext: Callback = ( context, next ) => {
	const { tab = TAB_ACTIVE_MEMBERS } = context.params;
	context.secondary = <MainSidebar path={ context.path } />;
	context.primary = (
		<>
			<PageViewTracker title="Manage team" path={ context.path } />
			<TeamList currentTab={ tab } />
		</>
	);

	next();
};

export const teamInviteContext: Callback = ( context, next ) => {
	context.secondary = <MainSidebar path={ context.path } />;
	context.primary = (
		<>
			<PageViewTracker title="Manage team > Invite a team member" path={ context.path } />
			<TeamInvite />
		</>
	);

	next();
};

export const teamAcceptInviteContext: Callback = ( context, next ) => {
	const { agency_id: agencyId, invite_id: inviteId, secret: secret } = context.query;

	context.primary = (
		<>
			<PageViewTracker title="Accept team invite" path={ context.path } />
			<TeamAcceptInvite agencyId={ agencyId } inviteId={ inviteId } secret={ secret } />
		</>
	);

	next();
};