11import { Button } from '@cmsgov/design-system' ;
22import axios from 'axios' ;
33import chart from '../images/who-charted.png'
4- // import { SettingsType } from '../types/settings';
4+ import { SettingsType } from '../types/settings' ;
55import React , { useState } from 'react' ;
66import * as process from 'process' ;
77
88export default function PatientData ( ) {
99 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+ } ) ;
1913 async function goAuthorize ( ) {
20- // comment out '{ params: settingsState }' since /api/authorize/authurl does not take params
2114 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` )
2316 . then ( response => {
2417 return response . data ;
2518 } )
@@ -30,7 +23,11 @@ export default function PatientData() {
3023 window . location . href = "/" ;
3124 } ) ;
3225 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+ }
3431
3532 /* DEVELOPER NOTES:
3633 * Here we are hard coding the users information for the sake of saving time
@@ -50,7 +47,16 @@ export default function PatientData() {
5047 < div >
5148 < h4 > { header } </ h4 >
5249 </ 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+ }
5460 </ div >
5561 </ div >
5662 ) ;
0 commit comments