import { observer } from 'mobx-react' import { useState } from 'react' import { CountDown, Toast } from 'react-vant' import useLike from '~/hooks/useLike' import { useRouter } from '~/hooks/useRouter' import store from '~/store' import '~/styles/components.scss' import { MarketNFTData } from '~/types/store' import { getTime, toThousands } from '~/utils' import { copy } from '~/utils/copy' import Modal from './Modal' interface ProductInfoProps { data: MarketNFTData } const ProductInfo = (props: ProductInfoProps) => { const { data } = props const { push } = useRouter() const { likeNft, userInfo } = store.state const { setLike, isLike } = useLike() const [visible, setVisible] = useState(false) const [visibleTime, setVisibleTime] = useState(false) const share = () => { const pathname = `${process.env.REACT_APP_SHARE_LINK}detail?id=${data.id}&type=${data.type}` copy(pathname) setVisible(true) } const toShare = (type: "cast" | "sell") => { if (type === 'cast') { if (data.cast_id === userInfo.id) { push('/share') return } if (data.cast_show === 1) { push('/noShare', { id: data.cast_id }) } else { Toast.fail('對方未開放') } } if (type === 'sell') { if (data.sell_id === userInfo.id) { push('/share') return } if (data.sell_show === 1) { push('/noShare', { id: data.sell_id }) } else { Toast.fail('對方未開放') } } } return (
{data.type === 1 && !visibleTime &&
setVisibleTime(true)} />
} {data.type === 3 && !visibleTime &&
setVisibleTime(true)} />
} {data.type !== 0 &&
{data.type !== 3 && setLike(data.id)} />}
}
{data.name}
{data.symbol} {toThousands(data.price)}
toShare('cast')}>
鑄造者
{data.cast_name}
{data.type === 3 ? (
當前編號:{data.current_number}
剩餘數量:{data.remain_quantity}
) : (
toShare('sell')}>
售賣者
{data.sell_name}
) }
已複製鏈接
) } export default observer(ProductInfo)