// @flow import moment from 'moment'; import React, { Component } from 'react'; import { If, Then, Else } from 'react-if'; import { Layout, Container, Header } from './Layout'; import Switch from './Switch'; import CustomScrollbars from './CustomScrollbars'; import type { AccountReduxState } from '../redux/account/reducers'; import type { SettingsReduxState } from '../redux/settings/reducers'; export type SettingsProps = { account: AccountReduxState, settings: SettingsReduxState, onQuit: () => void, onClose: () => void, onViewAccount: () => void, onExternalLink: (type: string) => void, onUpdateSettings: (update: $Shape) => void }; export default class Settings extends Component { props: SettingsProps; onClose = () => this.props.onClose(); onAutoSecure = (autoSecure: boolean) => this.props.onUpdateSettings({ autoSecure }); onExternalLink(type: string) { this.props.onExternalLink(type); } render(): React.Element<*> { const isLoggedIn = this.props.account.status === 'ok'; let isOutOfTime = false, formattedPaidUntil = ''; let paidUntilIso = this.props.account.paidUntil; if(isLoggedIn && paidUntilIso) { let paidUntil = moment(this.props.account.paidUntil); isOutOfTime = paidUntil.isSameOrBefore(moment()); formattedPaidUntil = paidUntil.fromNow(true) + ' left'; } return (