2020-02-19 07:31:40 +01:00
// @flow
import React , { useState } from 'react' ;
import Button from 'component/button' ;
import I18nMessage from 'component/i18nMessage' ;
import { FormField } from 'component/common/form-components/form-field' ;
import { Form } from 'component/common/form-components/form' ;
import { withRouter } from 'react-router-dom' ;
// $FlowFixMe cannot resolve ...
2022-04-01 21:10:32 +02:00
import image from 'static/img/yrblsec.svg' ;
2020-02-19 07:31:40 +01:00
const LIMITED = 'limited' ;
const NONE = 'none' ;
type Props = {
2021-11-28 21:05:10 +01:00
setWelcomeVersion : ( number ) => void ,
2020-02-24 19:20:45 +01:00
signOut : ( ) => void ,
2021-11-28 21:05:10 +01:00
setShareDataInternal : ( boolean ) => void ,
setShareDataThirdParty : ( boolean ) => void ,
2020-02-24 19:20:45 +01:00
authenticated : boolean ,
2021-01-25 18:35:54 +01:00
authenticateIfSharingData : ( ) => void ,
2022-04-01 21:10:32 +02:00
handleNextPage : ( ) => void ,
2020-02-19 07:31:40 +01:00
} ;
function PrivacyAgreement ( props : Props ) {
2021-01-25 18:35:54 +01:00
const {
setShareDataInternal ,
setShareDataThirdParty ,
authenticated ,
signOut ,
authenticateIfSharingData ,
2022-04-01 21:10:32 +02:00
handleNextPage ,
2021-01-25 18:35:54 +01:00
} = props ;
2020-02-19 07:31:40 +01:00
const [ share , setShare ] = useState ( undefined ) ; // preload
function handleSubmit ( ) {
2022-04-01 21:10:32 +02:00
if ( share === LIMITED ) {
2020-02-19 07:31:40 +01:00
setShareDataInternal ( true ) ;
setShareDataThirdParty ( false ) ;
} else {
setShareDataInternal ( false ) ;
setShareDataThirdParty ( false ) ;
}
2021-01-25 18:35:54 +01:00
2022-04-01 21:10:32 +02:00
if ( share === LIMITED ) {
2021-01-25 18:35:54 +01:00
authenticateIfSharingData ( ) ;
}
2022-04-01 21:10:32 +02:00
// setWelcomeVersion(WELCOME_VERSION);
handleNextPage ( ) ;
// history.replace(`/`);
2020-02-19 07:31:40 +01:00
}
return (
< section className = "main--contained" >
2022-04-01 21:10:32 +02:00
< div className = { 'columns first-run__wrapper' } >
< div className = { 'first-run__left' } >
< div >
< h1 className = "section__title--large" > { _ _ ( 'Privacy' ) } < / h1 >
< h3 className = "section__subtitle" >
{ _ _ (
` LBRY takes privacy and choice seriously. Is it ok if we monitor performance and help creators track their views? `
) }
< / h3 >
< / div >
< Form onSubmit = { handleSubmit } className = "section__body" >
< fieldset >
< FormField
name = { 'shareWithLBRY' }
type = "radio"
checked = { share === LIMITED }
label = {
< >
{ _ _ ( 'Yes, share with LBRY' ) } < span > 🙂 < / span >
< / >
}
onChange = { ( e ) => setShare ( LIMITED ) }
/ >
< FormField
disabled = { authenticated }
name = { 'shareNot' }
type = "radio"
checked = { share === NONE }
label = {
< >
{ _ _ ( 'No' ) } < span > 😢 < / span >
< / >
}
helper = { _ _ ( ` * Note that as
2020-02-19 07:31:40 +01:00
peer - to - peer software , your IP address and potentially other system information can be sent to other
users , though this information is not stored permanently . ` )}
2022-04-01 21:10:32 +02:00
onChange = { ( e ) => setShare ( NONE ) }
/ >
{ authenticated && (
< div className = "card--inline section--padded" >
< p className = "help--inline" >
< I18nMessage
tokens = { {
signout _button : < Button button = "link" label = { _ _ ( 'Sign Out' ) } onClick = { signOut } / > ,
} }
>
You are signed in and sharing data with your cloud service provider . % signout _button % .
< / I18nMessage >
< / p >
< / div >
) }
< / fieldset >
< div className = { 'card__actions' } >
< Button button = "primary" label = { _ _ ( ` Let's go ` ) } disabled = { ! share } type = "submit" / >
2020-02-24 19:20:45 +01:00
< / div >
2022-04-01 21:10:32 +02:00
{ share === NONE && (
< p className = "help" >
{ _ _ (
'While we respect the desire for maximally private usage, please note that choosing this option hurts the ability for creators to understand how their content is performing.'
) }
< / p >
) }
< / Form >
2020-02-24 19:20:45 +01:00
< / div >
2022-04-01 21:10:32 +02:00
< div className = { 'first-run__image-wrapper' } >
< img src = { image } className = "privacy-img" / >
2020-02-19 07:31:40 +01:00
< / div >
2022-04-01 21:10:32 +02:00
< / div >
2020-02-19 07:31:40 +01:00
< / section >
) ;
}
export default withRouter ( PrivacyAgreement ) ;