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 ...
import image from 'static/img/unlocklbry.svg' ;
2020-06-02 22:52:34 +02:00
import { WELCOME _VERSION } from 'config' ;
2020-02-19 07:31:40 +01:00
const FREE = 'free' ;
const LIMITED = 'limited' ;
const NONE = 'none' ;
type Props = {
2021-10-11 03:43:29 +02:00
setWelcomeVersion : number => void ,
2020-02-24 19:20:45 +01:00
signOut : ( ) => void ,
2021-10-11 03:43:29 +02:00
setShareDataInternal : boolean => void ,
setShareDataThirdParty : boolean => void ,
history : { replace : string => void } ,
2020-02-24 19:20:45 +01:00
authenticated : boolean ,
2021-01-25 18:35:54 +01:00
authenticateIfSharingData : ( ) => void ,
2020-02-19 07:31:40 +01:00
} ;
function PrivacyAgreement ( props : Props ) {
2021-01-25 18:35:54 +01:00
const {
setWelcomeVersion ,
setShareDataInternal ,
setShareDataThirdParty ,
history ,
authenticated ,
signOut ,
authenticateIfSharingData ,
} = props ;
2020-02-19 07:31:40 +01:00
const [ share , setShare ] = useState ( undefined ) ; // preload
const [ agree , setAgree ] = useState ( false ) ; // preload
function handleSubmit ( ) {
if ( share === FREE ) {
setShareDataInternal ( true ) ;
setShareDataThirdParty ( true ) ;
} else if ( share === LIMITED ) {
setShareDataInternal ( true ) ;
setShareDataThirdParty ( false ) ;
} else {
setShareDataInternal ( false ) ;
setShareDataThirdParty ( false ) ;
}
2021-01-25 18:35:54 +01:00
if ( share === FREE || share === LIMITED ) {
authenticateIfSharingData ( ) ;
}
2020-06-02 22:52:34 +02:00
setWelcomeVersion ( WELCOME _VERSION ) ;
2020-02-19 07:31:40 +01:00
history . replace ( ` / ` ) ;
}
return (
< section className = "main--contained" >
< div className = { 'columns' } >
< div >
< h1 className = "section__title--large" > { _ _ ( 'Welcome' ) } < / h1 >
< h3 className = "section__subtitle" >
{ _ _ (
2020-06-04 23:20:27 +02:00
` LBRY takes privacy and choice seriously. Just a few questions before you enter the land of content freedom. `
2020-02-19 07:31:40 +01:00
) }
< / h3 >
< / div >
< div >
2020-02-21 23:05:10 +01:00
< img src = { image } className = "privacy-img" / >
2020-02-19 07:31:40 +01:00
< / div >
< / div >
2020-02-21 23:05:10 +01:00
< hr / >
2020-02-24 19:20:45 +01:00
< p className = "section__body section__subtitle" >
{ _ _ ( 'Can this app send information about your usage to inform publishers and improve the software?' ) }
< / p >
2020-02-19 07:31:40 +01:00
< Form onSubmit = { handleSubmit } className = "section__body" >
< fieldset >
< FormField
name = { 'shareFreely' }
type = "radio"
label = {
< >
2020-02-21 23:05:10 +01:00
{ _ _ ( 'Yes, including with third-party analytics platforms' ) } < span > 😄 < / span >
2020-02-19 07:31:40 +01:00
< / >
}
helper = { _ _ ( ` Sending information to third parties (e.g. Google Analytics or Mixpanel) allows us to use detailed
analytical reports to improve all aspects of LBRY . ` )}
checked = { share === FREE }
2021-10-11 03:43:29 +02:00
onChange = { e => setShare ( FREE ) }
2020-02-19 07:31:40 +01:00
/ >
< FormField
name = { 'shareWithLBRY' }
type = "radio"
checked = { share === LIMITED }
label = {
< >
2020-02-21 23:05:10 +01:00
{ _ _ ( 'Yes, but only with LBRY, Inc.' ) } < span > 🙂 < / span >
2020-02-19 07:31:40 +01:00
< / >
}
helper = { _ _ (
` Sharing information with LBRY, Inc. allows us to report to publishers how their content is doing, as
well as track basic usage and performance . This is the minimum required to earn rewards from LBRY , Inc . `
) }
2021-10-11 03:43:29 +02:00
onChange = { e => setShare ( LIMITED ) }
2020-02-19 07:31:40 +01:00
/ >
< FormField
2020-02-24 19:20:45 +01:00
disabled = { authenticated }
2020-02-19 07:31:40 +01:00
name = { 'shareNot' }
type = "radio"
checked = { share === NONE }
label = {
< >
2020-02-21 23:05:10 +01:00
{ _ _ ( 'No' ) } < span > 😢 < / span >
2020-02-19 07:31:40 +01:00
< / >
}
helper = { _ _ ( ` No information will be sent directly to LBRY, Inc. or third-parties about your usage. Note that as
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 . ` )}
2021-10-11 03:43:29 +02:00
onChange = { e => setShare ( NONE ) }
2020-02-19 07:31:40 +01:00
/ >
2020-02-24 19:20:45 +01:00
{ 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 into lbry . tv which automatically shares data with LBRY inc . % signout _button % .
< / I18nMessage >
< / p >
< / div >
) }
2020-02-19 07:31:40 +01:00
< / fieldset >
2020-02-24 19:20:45 +01:00
< div className = "section__body" >
< p className = "section__subtitle" >
< I18nMessage
tokens = { {
2021-10-11 03:43:29 +02:00
terms : (
< Button button = "link" href = "https://www.lbry.com/termsofservice" label = { _ _ ( 'Terms of Service' ) } / >
) ,
2020-02-24 19:20:45 +01:00
} }
>
Do you agree to the % terms % ?
< / I18nMessage >
< / p >
< fieldset >
< FormField
name = { 'agreeButton' }
type = "radio"
label = { 'Yes' }
checked = { agree === true }
2021-10-11 03:43:29 +02:00
onChange = { e => setAgree ( e . target . checked ) }
2020-02-24 19:20:45 +01:00
/ >
< FormField
name = { 'disagreeButton' }
type = "radio"
checked = { agree === false }
label = { _ _ ( 'No' ) }
2021-10-11 03:43:29 +02:00
onChange = { e => setAgree ( ! e . target . checked ) }
2020-02-24 19:20:45 +01:00
/ >
< / fieldset >
< / div >
2020-02-19 07:31:40 +01:00
< div className = { 'card__actions' } >
< Button button = "primary" label = { _ _ ( ` Let's go ` ) } disabled = { ! share || ! agree } type = "submit" / >
< / div >
2020-02-24 19:20:45 +01: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 >
) }
2020-02-19 07:31:40 +01:00
< / Form >
< / section >
) ;
}
export default withRouter ( PrivacyAgreement ) ;