forked from Sage-Bionetworks/synapse-web-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Sage-Bionetworks#1252 from jay-hodgson/SWC-6533
SWC-6533
- Loading branch information
Showing
44 changed files
with
628 additions
and
545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
apps/SageAccountWeb/src/components/SignUpdatedTermsOfUsePage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React, { useState } from 'react' | ||
import { | ||
displayToast, | ||
SynapseContextUtils, | ||
SynapseQueries, | ||
GovernanceMarkdownGithub, | ||
restoreLastPlace, | ||
} from 'synapse-react-client' | ||
import { | ||
Box, | ||
Button, | ||
Checkbox, | ||
Container, | ||
FormControlLabel, | ||
Paper, | ||
} from '@mui/material' | ||
import { StyledOuterContainer } from './StyledComponents' | ||
import { TermsOfServiceState } from '@sage-bionetworks/synapse-types' | ||
|
||
export type SignUpdatedTermsOfUsePageProps = {} | ||
|
||
export const SignUpdatedTermsOfUsePage = ( | ||
props: SignUpdatedTermsOfUsePageProps, | ||
) => { | ||
const [isLoading, setIsLoading] = useState(false) | ||
const [isCheckboxSelected, setIsCheckboxSelected] = useState(false) | ||
const { accessToken } = SynapseContextUtils.useSynapseContext() | ||
const { mutate: signTermsOfService } = SynapseQueries.useSignTermsOfService() | ||
|
||
const { data: tosInfo } = SynapseQueries.useTermsOfServiceInfo() | ||
const { data: tosStatus } = SynapseQueries.useTermsOfServiceStatus() | ||
|
||
const isSkipAvailable = | ||
tosStatus?.usersCurrentTermsOfServiceState == | ||
TermsOfServiceState.MUST_AGREE_SOON | ||
const onSignTermsOfUse = async (event: React.SyntheticEvent) => { | ||
event.preventDefault() | ||
setIsLoading(true) | ||
try { | ||
if (accessToken) { | ||
signTermsOfService( | ||
{ | ||
accessToken, | ||
termsOfServiceVersion: tosInfo?.latestTermsOfServiceVersion!, | ||
}, | ||
{ | ||
onSuccess: () => { | ||
restoreLastPlace() | ||
}, | ||
onError: err => { | ||
displayToast(err.reason as string, 'danger') | ||
}, | ||
}, | ||
) | ||
} | ||
} catch (err: any) { | ||
displayToast(err.reason as string, 'danger') | ||
} finally { | ||
setIsLoading(false) | ||
} | ||
} | ||
|
||
return ( | ||
<StyledOuterContainer className="SignUpdatedTermsOfUsePage"> | ||
<Container sx={{ maxWidth: '800px' }}> | ||
<Paper> | ||
<GovernanceMarkdownGithub | ||
repoOwner="Sage-Bionetworks" | ||
repoName="Sage-Governance-Documents" | ||
filePath="Terms.md" | ||
/> | ||
<FormControlLabel | ||
control={<Checkbox />} | ||
sx={{ p: '30px 45px' }} | ||
label="I agree to the terms of service" | ||
checked={isCheckboxSelected} | ||
onChange={() => { | ||
setIsCheckboxSelected(!isCheckboxSelected) | ||
}} | ||
/> | ||
<Box | ||
sx={{ | ||
display: 'grid', | ||
gridTemplateColumns: isSkipAvailable ? 'repeat(2, 1fr)' : '1fr', // either 2 fr (fraction unit) or 1 | ||
gap: '10px', | ||
p: '0px 45px 45px 45px', | ||
}} | ||
> | ||
<Button | ||
variant="contained" | ||
sx={{ width: '100%' }} | ||
onClick={onSignTermsOfUse} | ||
disabled={isLoading || !isCheckboxSelected} | ||
> | ||
Agree and Continue | ||
</Button> | ||
{isSkipAvailable && ( | ||
<Button | ||
variant="outlined" | ||
sx={{ width: '100%' }} | ||
onClick={() => { | ||
sessionStorage.setItem('skippedSigningToS', 'true') | ||
restoreLastPlace() | ||
}} | ||
disabled={isLoading} | ||
> | ||
Skip for Now | ||
</Button> | ||
)} | ||
</Box> | ||
</Paper> | ||
</Container> | ||
</StyledOuterContainer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.