de6c6f9bfd
* Add option to pass in url-search params. Impetus: allow linked comment ID and setting the discussion tab when clicking on the `ClaimPreview`. * comment.list: fix typos and renamed variables - Switch from 'author' to 'creator' to disambiguate between comment author and content author. For comment author, we'll use 'commenter' from now on. - Corrected 'commenterClaimId' to 'creatorClaimId' (just a typo, no functional change). * doCommentReset: change param from uri to claimId This reduces one lookup as clients will always have the claimID ready, but might not have the full URI. It was using URI previously just to match the other APIs. * Add doCommentListOwn -- command to fetch own comments Since the redux slice is set up based on content or channel ID (for Channel Discussion page), re-use the channel ID for the case of "own comments". We always clear each ID when fetching page-0, so no worries of conflict when actually browsing the Channel Discussion page. * Comment: add option to hide the actions section * Implement own-comments page * Use new param to remove sort-pins-first. comment.List currently always pushes pins to the top to support pagination. This new param removes this behavior.
112 lines
3.5 KiB
JavaScript
112 lines
3.5 KiB
JavaScript
// @flow
|
|
import * as ICONS from 'constants/icons';
|
|
import * as PAGES from 'constants/pages';
|
|
import { SETTINGS_GRP } from 'constants/settings';
|
|
import React from 'react';
|
|
import Button from 'component/button';
|
|
import Card from 'component/common/card';
|
|
import SettingsRow from 'component/settingsRow';
|
|
import SyncToggle from 'component/syncToggle';
|
|
import { getPasswordFromCookie } from 'util/saved-passwords';
|
|
import { getStripeEnvironment } from 'util/stripe';
|
|
|
|
type Props = {
|
|
// --- select ---
|
|
isAuthenticated: boolean,
|
|
walletEncrypted: boolean,
|
|
user: User,
|
|
myChannels: ?Array<ChannelClaim>,
|
|
// --- perform ---
|
|
doWalletStatus: () => void,
|
|
};
|
|
|
|
export default function SettingAccount(props: Props) {
|
|
const { isAuthenticated, walletEncrypted, user, myChannels, doWalletStatus } = props;
|
|
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 (
|
|
<>
|
|
<div className="card__title-section">
|
|
<h2 className="card__title">{__('Account')}</h2>
|
|
</div>
|
|
|
|
<Card
|
|
id={SETTINGS_GRP.ACCOUNT}
|
|
isBodyList
|
|
body={
|
|
<>
|
|
{isAuthenticated && (
|
|
<SettingsRow title={__('Password')}>
|
|
<Button
|
|
button="inverse"
|
|
label={__('Manage')}
|
|
icon={ICONS.ARROW_RIGHT}
|
|
navigate={`/$/${PAGES.SETTINGS_UPDATE_PWD}`}
|
|
/>
|
|
</SettingsRow>
|
|
)}
|
|
|
|
{/* @if TARGET='app' */}
|
|
<SyncToggle disabled={walletEncrypted && !storedPassword && storedPassword !== ''} />
|
|
{/* @endif */}
|
|
|
|
{/* @if TARGET='web' */}
|
|
{user && getStripeEnvironment() && (
|
|
<SettingsRow
|
|
title={__('Bank Accounts')}
|
|
subtitle={__('Connect a bank account to receive tips and compensation in your local currency.')}
|
|
>
|
|
<Button
|
|
button="inverse"
|
|
label={__('Manage')}
|
|
icon={ICONS.ARROW_RIGHT}
|
|
navigate={`/$/${PAGES.SETTINGS_STRIPE_ACCOUNT}`}
|
|
/>
|
|
</SettingsRow>
|
|
)}
|
|
{/* @endif */}
|
|
|
|
{/* @if TARGET='web' */}
|
|
{isAuthenticated && getStripeEnvironment() && (
|
|
<SettingsRow
|
|
title={__('Payment Methods')}
|
|
subtitle={__('Add a credit card to tip creators in their local currency.')}
|
|
>
|
|
<Button
|
|
button="inverse"
|
|
label={__('Manage')}
|
|
icon={ICONS.ARROW_RIGHT}
|
|
navigate={`/$/${PAGES.SETTINGS_STRIPE_CARD}`}
|
|
/>
|
|
</SettingsRow>
|
|
)}
|
|
{/* @endif */}
|
|
|
|
{myChannels && (
|
|
<SettingsRow title={__('Comments')} subtitle={__('View your past comments.')}>
|
|
<Button
|
|
button="inverse"
|
|
label={__('Manage')}
|
|
icon={ICONS.ARROW_RIGHT}
|
|
navigate={`/$/${PAGES.SETTINGS_OWN_COMMENTS}`}
|
|
/>
|
|
</SettingsRow>
|
|
)}
|
|
</>
|
|
}
|
|
/>
|
|
</>
|
|
);
|
|
}
|