File size: 1,144 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
import page, { type Callback } from '@automattic/calypso-router';
import { createElement } from 'react';
import isJetpackCloud from 'calypso/lib/jetpack/is-jetpack-cloud';
import JetpackMonetize from './jetpack-monetize';
import Main from './main';

const earnPath = ! isJetpackCloud() ? '/earn' : '/monetize';

export const redirectToAdsEarnings: Callback = ( context ) => {
	page.redirect( earnPath + '/ads-earnings/' + context.params.site_id );
};

export const redirectToAdsSettings: Callback = ( context ) => {
	page.redirect( earnPath + '/ads-settings/' + context.params.site_id );
};

export const redirectToSettings: Callback = ( context ) => {
	page.redirect( earnPath + '/payments/' + context.params.site_id );
};

export const layout: Callback = ( context, next ) => {
	// Scroll to the top
	if ( typeof window !== 'undefined' ) {
		window.scrollTo( 0, 0 );
	}

	context.primary = createElement( Main, {
		section: context.params.section,
		path: context.path,
		query: context.query,
	} );
	next();
};

export const jetpackMonetize: Callback = ( context, next ) => {
	context.primary = createElement( JetpackMonetize );
	next();
};