2021-08-05 09:00:21 +02:00
|
|
|
// @flow
|
2021-08-06 09:43:21 +02:00
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import * as PAGES from 'constants/pages';
|
2021-08-08 10:13:35 +02:00
|
|
|
import { SETTINGS_GRP } from 'constants/settings';
|
2021-08-05 09:00:21 +02:00
|
|
|
import React from 'react';
|
2021-08-06 09:43:21 +02:00
|
|
|
import Button from 'component/button';
|
2021-08-05 09:00:21 +02:00
|
|
|
import Card from 'component/common/card';
|
2021-08-06 09:43:21 +02:00
|
|
|
import SettingsRow from 'component/settingsRow';
|
2021-08-05 09:00:21 +02:00
|
|
|
import SyncToggle from 'component/syncToggle';
|
|
|
|
import { getPasswordFromCookie } from 'util/saved-passwords';
|
2021-08-06 09:43:21 +02:00
|
|
|
import { getStripeEnvironment } from 'util/stripe';
|
2021-08-05 09:00:21 +02:00
|
|
|
|
|
|
|
type Props = {
|
2021-11-08 07:27:14 +01:00
|
|
|
// --- redux ---
|
2021-08-05 09:00:21 +02:00
|
|
|
isAuthenticated: boolean,
|
|
|
|
walletEncrypted: boolean,
|
2021-08-06 09:43:21 +02:00
|
|
|
user: User,
|
2021-11-08 07:27:14 +01:00
|
|
|
hasChannels: boolean,
|
2021-08-05 09:00:21 +02:00
|
|
|
doWalletStatus: () => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function SettingAccount(props: Props) {
|
2021-11-08 07:27:14 +01:00
|
|
|
const { isAuthenticated, walletEncrypted, user, hasChannels, doWalletStatus } = props;
|
2021-08-05 09:00:21 +02:00
|
|
|
const [storedPassword, setStoredPassword] = React.useState(false);
|
|
|
|
|
|
|
|
// Determine if password is stored.
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (isAuthenticated || !IS_WEB) {
|
|
|
|
doWalletStatus();
|
|
|
|
getPasswordFromCookie().then((p) => {
|
|
|
|
if (typeof p === 'string') {
|
|
|
|
setStoredPassword(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
|
|
|
|
return (
|
2021-08-09 04:22:16 +02:00
|
|
|
<>
|
|
|
|
<div className="card__title-section">
|
|
|
|
<h2 className="card__title">{__('Account')}</h2>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<Card
|
|
|
|
id={SETTINGS_GRP.ACCOUNT}
|
|
|
|
isBodyList
|
|
|
|
body={
|
|
|
|
<>
|
|
|
|
{isAuthenticated && (
|
2021-08-23 08:18:27 +02:00
|
|
|
<SettingsRow title={__('Password')}>
|
|
|
|
<Button
|
|
|
|
button="inverse"
|
|
|
|
label={__('Manage')}
|
|
|
|
icon={ICONS.ARROW_RIGHT}
|
|
|
|
navigate={`/$/${PAGES.SETTINGS_UPDATE_PWD}`}
|
|
|
|
/>
|
|
|
|
</SettingsRow>
|
2021-08-09 04:22:16 +02:00
|
|
|
)}
|
|
|
|
|
|
|
|
{/* @if TARGET='app' */}
|
2021-08-23 08:50:25 +02:00
|
|
|
<SyncToggle disabled={walletEncrypted && !storedPassword && storedPassword !== ''} />
|
2021-08-09 04:22:16 +02:00
|
|
|
{/* @endif */}
|
2021-08-05 09:00:21 +02:00
|
|
|
|
2021-08-09 04:22:16 +02:00
|
|
|
{/* @if TARGET='web' */}
|
|
|
|
{user && getStripeEnvironment() && (
|
|
|
|
<SettingsRow
|
|
|
|
title={__('Bank Accounts')}
|
2021-08-27 06:42:23 +02:00
|
|
|
subtitle={__('Connect a bank account to receive tips and compensation in your local currency.')}
|
2021-08-09 04:22:16 +02:00
|
|
|
>
|
|
|
|
<Button
|
2021-08-19 16:38:15 +02:00
|
|
|
button="inverse"
|
2021-08-09 04:22:16 +02:00
|
|
|
label={__('Manage')}
|
2021-08-19 16:38:15 +02:00
|
|
|
icon={ICONS.ARROW_RIGHT}
|
2021-08-09 04:22:16 +02:00
|
|
|
navigate={`/$/${PAGES.SETTINGS_STRIPE_ACCOUNT}`}
|
|
|
|
/>
|
|
|
|
</SettingsRow>
|
|
|
|
)}
|
|
|
|
{/* @endif */}
|
2021-08-06 09:43:21 +02:00
|
|
|
|
2021-08-09 04:22:16 +02:00
|
|
|
{/* @if TARGET='web' */}
|
|
|
|
{isAuthenticated && getStripeEnvironment() && (
|
|
|
|
<SettingsRow
|
|
|
|
title={__('Payment Methods')}
|
2021-08-27 06:42:23 +02:00
|
|
|
subtitle={__('Add a credit card to tip creators in their local currency.')}
|
2021-08-09 04:22:16 +02:00
|
|
|
>
|
|
|
|
<Button
|
2021-08-19 16:38:15 +02:00
|
|
|
button="inverse"
|
2021-08-09 04:22:16 +02:00
|
|
|
label={__('Manage')}
|
2021-08-19 16:38:15 +02:00
|
|
|
icon={ICONS.ARROW_RIGHT}
|
2021-08-09 04:22:16 +02:00
|
|
|
navigate={`/$/${PAGES.SETTINGS_STRIPE_CARD}`}
|
|
|
|
/>
|
|
|
|
</SettingsRow>
|
|
|
|
)}
|
|
|
|
{/* @endif */}
|
2021-10-01 14:10:27 +02:00
|
|
|
|
2021-11-08 07:27:14 +01:00
|
|
|
{hasChannels && (
|
2021-10-01 14:10:27 +02:00
|
|
|
<SettingsRow title={__('Comments')} subtitle={__('View your past comments.')}>
|
|
|
|
<Button
|
|
|
|
button="inverse"
|
|
|
|
label={__('Manage')}
|
|
|
|
icon={ICONS.ARROW_RIGHT}
|
|
|
|
navigate={`/$/${PAGES.SETTINGS_OWN_COMMENTS}`}
|
|
|
|
/>
|
|
|
|
</SettingsRow>
|
|
|
|
)}
|
2022-04-07 18:10:39 +02:00
|
|
|
|
|
|
|
<SettingsRow title={__('Purchases')} subtitle={__('View your purchased content.')}>
|
|
|
|
<Button button="inverse" label={__('Manage')} icon={ICONS.ARROW_RIGHT} navigate={`/$/${PAGES.LIBRARY}`} />
|
|
|
|
</SettingsRow>
|
2021-08-09 04:22:16 +02:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</>
|
2021-08-05 09:00:21 +02:00
|
|
|
);
|
|
|
|
}
|