File size: 976 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
import config from '@automattic/calypso-config';
import { createRoot } from 'react-dom/client';

import './style.scss';

function AuthHelper() {
	const isOAuth = config.isEnabled( 'oauth' );

	function setAuth( event ) {
		const value = event.currentTarget.value;
		window.location.href = '?' + new URLSearchParams( { flags: value } ).toString();
	}

	return (
		<>
			<div>Auth: { isOAuth ? 'OAuth' : 'Cookies' }</div>
			<div className="auth-helper__popover">
				<label className="auth-helper__label">
					<input
						type="radio"
						name="auth"
						value="-oauth"
						defaultChecked={ ! isOAuth }
						onChange={ setAuth }
					/>
					Cookies
				</label>
				<label className="auth-helper__label">
					<input
						type="radio"
						name="auth"
						value="oauth"
						defaultChecked={ isOAuth }
						onChange={ setAuth }
					/>
					OAuth
				</label>
			</div>
		</>
	);
}

export default ( element ) => createRoot( element ).render( <AuthHelper /> );