lbry-desktop/ui/component/syncToggle/view.jsx

52 lines
1.6 KiB
React
Raw Normal View History

2019-10-15 23:23:51 +02:00
// @flow
import * as MODALS from 'constants/modal_types';
2019-10-15 23:23:51 +02:00
import React from 'react';
import Button from 'component/button';
import SettingsRow from 'component/settingsRow';
import { withRouter } from 'react-router';
import { FormField } from 'component/common/form';
2019-10-15 23:23:51 +02:00
type Props = {
setSyncEnabled: (boolean) => void,
2019-10-15 23:23:51 +02:00
syncEnabled: boolean,
verifiedEmail: ?string,
history: { push: (string) => void },
location: UrlLocation,
getSyncError: ?string,
disabled: boolean,
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-15 23:23:51 +02:00
return (
<SettingsRow
title={__('Sync')}
subtitle={disabled || !verifiedEmail ? '' : __('Sync your balance and preferences across devices.')}
>
<FormField
type="checkbox"
name="sync_toggle"
label={disabled || !verifiedEmail ? __('Sync your balance and preferences across devices.') : undefined}
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 && (
<div>
<p className="help">{__('An email address is required to sync your account.')}</p>
<Button requiresAuth button="primary" label={__('Add Email')} />
</div>
2019-10-15 23:23:51 +02:00
)}
</SettingsRow>
2019-10-15 23:23:51 +02:00
);
}
export default withRouter(SyncToggle);