1
1
import { Button } from '@cmsgov/design-system' ;
2
2
import axios from 'axios' ;
3
3
import chart from '../images/who-charted.png'
4
- // import { SettingsType } from '../types/settings';
4
+ import { SettingsType } from '../types/settings' ;
5
5
import React , { useState } from 'react' ;
6
6
import * as process from 'process' ;
7
7
8
8
export default function PatientData ( ) {
9
9
const [ header ] = useState ( 'Add your Medicare Prescription Drug data' ) ;
10
- // comment out below because the end point /api/authorize/authurl of
11
- // the server component (on port 3001), does not take parameter such as pkce, version, env
12
- // they are generated by the server component.
13
- //
14
- // const [settingsState] = useState<SettingsType>({
15
- // pkce: true,
16
- // version: 'v2',
17
- // env: 'sandbox'
18
- // });
10
+ const [ settingsState ] = useState < SettingsType > ( {
11
+ useDefaultDataButton : false , // Set to true to use hard coded data
12
+ } ) ;
19
13
async function goAuthorize ( ) {
20
- // comment out '{ params: settingsState }' since /api/authorize/authurl does not take params
21
14
const test_url = process . env . TEST_APP_API_URL ? process . env . TEST_APP_API_URL : ''
22
- const authUrlResponseData = await axios . get ( `${ test_url } /api/authorize/authurl` /*, { params: settingsState } */ )
15
+ const authUrlResponseData = await axios . get ( `${ test_url } /api/authorize/authurl` )
23
16
. then ( response => {
24
17
return response . data ;
25
18
} )
@@ -30,7 +23,11 @@ export default function PatientData() {
30
23
window . location . href = "/" ;
31
24
} ) ;
32
25
console . log ( authUrlResponseData ) ;
33
- }
26
+ }
27
+ async function goLoadDefaults ( ) {
28
+ const loadDefaultsResponse = await axios . get ( `/api/bluebutton/loadDefaults` ) ;
29
+ window . location . href = loadDefaultsResponse . data || '/' ;
30
+ }
34
31
35
32
/* DEVELOPER NOTES:
36
33
* Here we are hard coding the users information for the sake of saving time
@@ -50,7 +47,16 @@ export default function PatientData() {
50
47
< div >
51
48
< h4 > { header } </ h4 >
52
49
</ div >
53
- < Button id = "auth_btn" variation = "solid" onClick = { goAuthorize } > Authorize</ Button >
50
+ < div className = 'ds-u-margin-top--2' >
51
+ < Button id = "auth_btn" variation = "solid" onClick = { goAuthorize } > Authorize</ Button >
52
+ </ div >
53
+ {
54
+ settingsState . useDefaultDataButton ?
55
+ < div className = 'ds-u-margin-top--2' >
56
+ < Button id = "load_defaults_btn" variation = "solid" onClick = { goLoadDefaults } > Load default data</ Button >
57
+ </ div > :
58
+ null
59
+ }
54
60
</ div >
55
61
</ div >
56
62
) ;
0 commit comments