2020-02-11 20:04:51 +01:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
2020-10-28 20:18:58 +01:00
|
|
|
import classnames from 'classnames';
|
2020-02-11 20:04:51 +01:00
|
|
|
import Page from 'component/page';
|
|
|
|
import ClaimListDiscover from 'component/claimListDiscover';
|
2020-02-12 16:10:17 +01:00
|
|
|
import ClaimEffectiveAmount from 'component/claimEffectiveAmount';
|
2020-10-28 20:18:58 +01:00
|
|
|
import SearchTopClaim from 'component/searchTopClaim';
|
2020-02-10 20:43:24 +01:00
|
|
|
import { ORDER_BY_TOP, FRESH_ALL } from 'constants/claim_search';
|
2020-10-28 20:18:58 +01:00
|
|
|
import Button from 'component/button';
|
2020-02-11 20:04:51 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
name: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
function TopPage(props: Props) {
|
|
|
|
const { name } = props;
|
2020-10-28 20:18:58 +01:00
|
|
|
const [channelActive, setChannelActive] = React.useState(false);
|
2020-02-11 20:04:51 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Page>
|
2020-10-28 20:18:58 +01:00
|
|
|
<SearchTopClaim query={name} hideLink />
|
2020-02-11 20:04:51 +01:00
|
|
|
<ClaimListDiscover
|
2020-10-28 20:18:58 +01:00
|
|
|
name={channelActive ? `@${name}` : name}
|
2020-02-10 20:43:24 +01:00
|
|
|
defaultFreshness={FRESH_ALL}
|
|
|
|
defaultOrderBy={ORDER_BY_TOP}
|
2020-10-23 20:57:40 +02:00
|
|
|
includeSupportAction
|
2020-02-12 16:10:17 +01:00
|
|
|
renderProperties={claim => (
|
2020-10-28 20:18:58 +01:00
|
|
|
<span className="claim-preview__custom-properties">
|
|
|
|
{claim.meta.is_controlling && <span className="help--inline">{__('Currently winning')}</span>}
|
2020-02-12 16:10:17 +01:00
|
|
|
<ClaimEffectiveAmount uri={claim.repost_url || claim.canonical_url} />
|
|
|
|
</span>
|
|
|
|
)}
|
2020-10-28 20:18:58 +01:00
|
|
|
header={
|
|
|
|
<div className="claim-search__top-row">
|
|
|
|
<Button
|
|
|
|
label={name}
|
|
|
|
button="alt"
|
|
|
|
onClick={() => setChannelActive(false)}
|
|
|
|
className={classnames('button-toggle', {
|
|
|
|
'button-toggle--active': !channelActive,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
label={`@${name}`}
|
|
|
|
button="alt"
|
|
|
|
onClick={() => setChannelActive(true)}
|
|
|
|
className={classnames('button-toggle', {
|
|
|
|
'button-toggle--active': channelActive,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
2020-02-11 20:04:51 +01:00
|
|
|
/>
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TopPage;
|