-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathTermsOfService.tsx
More file actions
64 lines (53 loc) · 1.83 KB
/
TermsOfService.tsx
File metadata and controls
64 lines (53 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React, { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { communities, identity } from '@quiet/state-manager'
import TermsOfServiceComponent from './TermsOfServiceComponent'
import { ModalName } from '../../sagas/modals/modals.types'
import { useModal } from '../../containers/hooks'
import { createLogger } from '../../logger'
import { shell } from 'electron'
const logger = createLogger('TermsOfService')
const TermsOfService = () => {
const dispatch = useDispatch()
const currentCommunity = useSelector(communities.selectors.currentCommunity)
const tosRequested = useSelector(communities.selectors.tosRequested)
const termsOfServiceModal = useModal(ModalName.termsOfServiceModal)
const loadingPanelModal = useModal(ModalName.loadingPanel)
const joinCommunityModal = useModal(ModalName.joinCommunityModal)
useEffect(() => {
if (tosRequested) {
logger.info('ToS requested by state-manager, opening ToS modal')
termsOfServiceModal.handleOpen()
}
}, [tosRequested])
const handleChoice = async (accepted: boolean) => {
if (accepted) {
if (!currentCommunity) {
loadingPanelModal.handleOpen()
}
} else {
logger.info('User declined ToS, aborting join process')
joinCommunityModal.handleOpen()
loadingPanelModal.handleClose()
}
dispatch(
communities.actions.setTermsOfServiceAccepted({
communityId: currentCommunity?.id,
accepted,
})
)
termsOfServiceModal.handleClose()
}
const openURL = () => {
shell.openExternal('https://github.com/TryQuiet/quiet/wiki/Privacy-Policy')
}
return (
<TermsOfServiceComponent
{...termsOfServiceModal}
handleClose={() => handleChoice(false)}
onChoose={handleChoice}
openURL={openURL}
/>
)
}
export default TermsOfService