Skip to content

Commit

Permalink
[DUOS-1692] Add reject ToS button (#1651)
Browse files Browse the repository at this point in the history
* add reject ToS button

* fixes
  • Loading branch information
connorlbark authored Jul 8, 2022
1 parent 6299717 commit 41537dd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Routes = (props) => (
<Route path="/nih_ic_webform" component={NIHICWebform} />
<Route path="/nih_pilot_info" component={NIHPilotInfo} />
<Route path="/privacy" component={PrivacyPolicy} />
<Route path="/tos" component={TermsOfService} />
<Route path="/tos" component={TermsOfService} props={props} />
<Route path="/tos_acceptance" component={TermsOfServiceAcceptance} props={props} />
<Route path="/data_sharing_language_tool" component={DataSharingLanguageTool} />
<AuthenticatedRoute path="/admin_console" component={AdminConsole} props={props} rolesAllowed={[USER_ROLES.admin]} />
Expand Down
5 changes: 5 additions & 0 deletions src/libs/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,11 @@ export const ToS = {
const url = `${await Config.getApiUrl()}/api/sam/register/self/tos`;
const res = await axios.post(url, {}, Config.authOpts());
return res.data;
},
rejectToS: async () => {
const url = `${await Config.getApiUrl()}/api/sam/register/self/tos`;
const res = await axios.delete(url, Config.authOpts());
return res.data;
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/libs/tosService.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ export const TosService = {
return await ToS.acceptToS();
},

rejectTos: async () => {
return await ToS.rejectToS();
},

};
40 changes: 36 additions & 4 deletions src/pages/TermsOfService.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import {div, h1} from 'react-hyperscript-helpers';
import {div, h1, h} from 'react-hyperscript-helpers';
import {useEffect, useState} from 'react';
import { Storage } from '../libs/storage';
import {TosService} from '../libs/tosService';
import SimpleButton from '../components/SimpleButton';


export default function TermsOfService() {
export default function TermsOfService(props) {

const [tosText, setTosText] = useState('');
const {history} = props;
const isLogged = Storage.userIsLogged();

useEffect(() => {
const init = async () => {
Expand All @@ -15,10 +19,38 @@ export default function TermsOfService() {
init();
}, []);

const rejectAndSignOut = async () => {
// update Sam that ToS was rejected
await TosService.rejectTos();

// log user out and send them back home.
await Storage.setUserIsLogged(false);
await Storage.clearStorage();
history.push('/');
};

return div({style: TosService.getBackgroundStyle()}, [
div({style: TosService.getContainerStyle()}, [
h1({style: {color: '#00609f', marginLeft: '25px'}}, ['DUOS Terms of Service']),
div({style: TosService.getScrollableStyle(), className: 'markdown-body'}, [tosText])
])
div({style: TosService.getScrollableStyle(), className: 'markdown-body'}, [tosText]),
div({isRendered: isLogged, style: {display: 'flex', justifyContent: 'right', paddingRight: '5rem'}}, [
h(SimpleButton, {
keyProp: 'tos-accept',
label: 'Reject Terms of Service',
isRendered: true,
onClick: rejectAndSignOut,
baseColor: '#d13b07',
hoverStyle: {
backgroundColor: '#b83206',
color: 'white'
},
additionalStyle: {
textTransform: 'none',
padding: '5px 10px',
fontSize: '1.45rem',
},
})
]),
]),
]);
}

0 comments on commit 41537dd

Please sign in to comment.