// @flow import * as React from 'react'; import * as ICONS from 'constants/icons'; import * as MODALS from 'constants/modal_types'; import { formatCredits } from 'lbry-redux'; import FileDetails from 'component/fileDetails'; import ClaimAuthor from 'component/claimAuthor'; import FileTitle from 'component/fileTitle'; import FileActions from 'component/fileActions'; import FileRenderInitiator from 'component/fileRenderInitiator'; import FileRenderInline from 'component/fileRenderInline'; import FileValues from 'component/fileValues'; import FileViewCount from 'component/fileViewCount'; import ClaimTags from 'component/claimTags'; import DateTime from 'component/dateTime'; import Button from 'component/button'; import LbcSymbol from 'component/common/lbc-symbol'; import classnames from 'classnames'; const EXPAND = { NONE: 'none', CREDIT_DETAILS: 'credit_details', FILE_DETAILS: 'file_details', }; type Props = { uri: string, claim: ?StreamClaim, claimIsMine: boolean, doOpenModal: (id: string, {}) => void, }; function PostViewer(props: Props) { const { uri, claim, claimIsMine, doOpenModal } = props; const [expand, setExpand] = React.useState(EXPAND.NONE); if (!claim) { return null; } const amount = parseFloat(claim.amount) + parseFloat(claim.meta.support_amount); const formattedAmount = formatCredits(amount, 2, true); const hasSupport = claim && claim.meta && claim.meta.support_amount && Number(claim.meta.support_amount) > 0; function handleExpand(newExpand) { if (expand === newExpand) { setExpand(EXPAND.NONE); } else { setExpand(newExpand); } } return (
{claimIsMine && hasSupport && (
{expand === EXPAND.CREDIT_DETAILS && (
)} {expand === EXPAND.FILE_DETAILS && (
)}
); } export default PostViewer;