2019-10-15 23:23:51 +02:00
|
|
|
// @flow
|
2020-09-11 20:35:50 +02:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
2019-10-15 23:23:51 +02:00
|
|
|
import React from 'react';
|
|
|
|
import Button from 'component/button';
|
2021-08-23 08:50:25 +02:00
|
|
|
import SettingsRow from 'component/settingsRow';
|
2019-10-16 07:01:18 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2020-09-11 20:35:50 +02:00
|
|
|
import { FormField } from 'component/common/form';
|
2019-10-15 23:23:51 +02:00
|
|
|
|
|
|
|
type Props = {
|
2021-08-05 09:00:21 +02:00
|
|
|
setSyncEnabled: (boolean) => void,
|
2019-10-15 23:23:51 +02:00
|
|
|
syncEnabled: boolean,
|
|
|
|
verifiedEmail: ?string,
|
2021-08-05 09:00:21 +02:00
|
|
|
history: { push: (string) => void },
|
2019-10-16 07:01:18 +02:00
|
|
|
location: UrlLocation,
|
|
|
|
getSyncError: ?string,
|
2019-10-17 21:15:32 +02:00
|
|
|
disabled: boolean,
|
2020-09-11 20:35:50 +02:00
|
|
|
openModal: (string, any) => void,
|
2019-10-15 23:23:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function SyncToggle(props: Props) {
|
2020-09-18 19:26:00 +02:00
|
|
|
const { verifiedEmail, openModal, syncEnabled, disabled } = props;
|
2019-10-16 07:01:18 +02:00
|
|
|
|
2019-10-15 23:23:51 +02:00
|
|
|
return (
|
2021-08-23 08:50:25 +02:00
|
|
|
<SettingsRow
|
|
|
|
title={__('Sync')}
|
|
|
|
subtitle={disabled || !verifiedEmail ? '' : __('Sync your balance and preferences across devices.')}
|
|
|
|
>
|
2021-08-05 09:00:21 +02:00
|
|
|
<FormField
|
|
|
|
type="checkbox"
|
|
|
|
name="sync_toggle"
|
2021-08-23 08:50:25 +02:00
|
|
|
label={disabled || !verifiedEmail ? __('Sync your balance and preferences across devices.') : undefined}
|
2021-08-05 09:00:21 +02:00
|
|
|
checked={syncEnabled && verifiedEmail}
|
|
|
|
onChange={() => openModal(MODALS.SYNC_ENABLE, { mode: syncEnabled ? 'disable' : 'enable' })}
|
|
|
|
disabled={disabled || !verifiedEmail}
|
|
|
|
helper={
|
|
|
|
disabled
|
|
|
|
? __("To enable Sync, close LBRY completely and check 'Remember Password' during wallet unlock.")
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
{!verifiedEmail && (
|
2019-10-16 07:01:18 +02:00
|
|
|
<div>
|
|
|
|
<p className="help">{__('An email address is required to sync your account.')}</p>
|
2021-08-05 09:00:21 +02:00
|
|
|
<Button requiresAuth button="primary" label={__('Add Email')} />
|
2019-10-16 07:01:18 +02:00
|
|
|
</div>
|
2019-10-15 23:23:51 +02:00
|
|
|
)}
|
2021-08-23 08:50:25 +02:00
|
|
|
</SettingsRow>
|
2019-10-15 23:23:51 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-10-16 07:01:18 +02:00
|
|
|
export default withRouter(SyncToggle);
|