// @flow import * as PAGES from 'constants/pages'; import * as MODALS from 'constants/modal_types'; import React from 'react'; import Button from 'component/button'; import { withRouter } from 'react-router'; import { FormField } from 'component/common/form'; type Props = { setSyncEnabled: boolean => void, syncEnabled: boolean, verifiedEmail: ?string, history: { push: string => void }, location: UrlLocation, getSyncError: ?string, disabled: boolean, openModal: (string, any) => void, }; function SyncToggle(props: Props) { const { verifiedEmail, getSyncError, history, location: { pathname }, openModal, syncEnabled, disabled, } = props; if (getSyncError) { history.push(`/$/${PAGES.AUTH}?redirect=${pathname}&immediate=true`); return null; } return (
{!verifiedEmail ? (
) : ( openModal(MODALS.SYNC_ENABLE, { mode: syncEnabled ? 'disable' : 'enable' })} disabled={disabled} /> )}
); } export default withRouter(SyncToggle);