Skip to content

Commit

Permalink
Control button for default data by client setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyfagan committed Dec 13, 2024
1 parent 026c135 commit 933d517
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
27 changes: 12 additions & 15 deletions client/src/components/patientData.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { Button } from '@cmsgov/design-system';
import axios from 'axios';
import chart from '../images/who-charted.png'
//import { SettingsType } from '../types/settings';
import { SettingsType } from '../types/settings';
import React, { useState } from 'react';
import * as process from 'process';

export default function PatientData() {
const [header] = useState('Add your Medicare Prescription Drug data');
// comment out below because the end point /api/authorize/authurl of
// the server component (on port 3001), does not take parameter such as pkce, version, env
// they are generated by the server component.
//
// const [settingsState] = useState<SettingsType>({
// pkce: true,
// version: 'v2',
// env: 'sandbox'
// });
const [settingsState] = useState<SettingsType>({
useDefaultDataButton: false, // Set to true to use hard coded data
});
async function goAuthorize() {
// comment out '{ params: settingsState }' since /api/authorize/authurl does not take params
const test_url = process.env.TEST_APP_API_URL ? process.env.TEST_APP_API_URL : ''
const authUrlResponseData = await axios.get(`${test_url}/api/authorize/authurl`/*, { params: settingsState } */)
const authUrlResponseData = await axios.get(`${test_url}/api/authorize/authurl`)
.then(response => {
return response.data;
})
Expand Down Expand Up @@ -57,9 +50,13 @@ export default function PatientData() {
<div className='ds-u-margin-top--2'>
<Button id="auth_btn" variation="primary" onClick={goAuthorize}>Authorize</Button>
</div>
<div className='ds-u-margin-top--2'>
<Button id="load_defaults_btn" variation="primary" onClick={goLoadDefaults}>Load default data</Button>
</div>
{
settingsState.useDefaultDataButton ?
<div className='ds-u-margin-top--2'>
<Button id="load_defaults_btn" variation="primary" onClick={goLoadDefaults}>Load default data</Button>
</div> :
null
}
</div>
</div>
);
Expand Down
4 changes: 1 addition & 3 deletions client/src/types/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type SettingsType = {
env: 'sandbox' | 'local' | 'production',
version: 'v1' | 'v2',
pkce: boolean,
useDefaultDataButton: boolean,
}

0 comments on commit 933d517

Please sign in to comment.