-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #490 from Psychedelic/fix/account-connect-home
Fix: 0.5.2 fixes + Jelly Activity integration
- Loading branch information
Showing
11 changed files
with
170 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import moment from 'moment'; | ||
import PropTypes from 'prop-types'; | ||
import NumberFormat from 'react-number-format'; | ||
|
||
import JellyIcon from '@assets/icons/jelly-icon.svg'; | ||
import { useICPPrice } from '@redux/icp'; | ||
import { E8S_PER_ICP } from '@shared/constants/currencies'; | ||
|
||
import ActivityItemDisplay from '../ActivityItemDisplay'; | ||
import ActivityItemDetails from '../ActivityItemDetails'; | ||
import GenericIcon from '../../../GenericIcon'; | ||
|
||
const getJellyEventTitle = (type) => ({ | ||
DIRECTBUY: 'Buy NFT', | ||
MAKELISTING: 'List NFT', | ||
CANCELLISTING: 'Cancel NFT Listing', | ||
MAKEOFFER: 'Make Offer', | ||
ACCEPTOFFER: 'Accept Offer', | ||
CANCELOFFER: 'Cancel Offer', | ||
DENYOFFER: 'Deny Offer', | ||
}[type]) || 'Jelly Event'; | ||
|
||
const getJellyData = (details, type, icpPrice) => { | ||
const { price: e8s, tokenId } = details || {}; | ||
const wicpAmount = e8s / E8S_PER_ICP; | ||
const title = getJellyEventTitle(type); | ||
const price = wicpAmount * icpPrice; | ||
return { | ||
price, title, tokenId, wicpAmount, | ||
}; | ||
}; | ||
|
||
const JellyItem = ({ | ||
date, | ||
details, | ||
setOpenDetail, | ||
hovering, | ||
type, | ||
}) => { | ||
const icpPrice = useICPPrice(); | ||
const [iconHovered, setIconHovered] = useState(false); | ||
const data = getJellyData(details, type, icpPrice); | ||
const mainDetail = iconHovered ? <NumberFormat value={data.wicpAmount} displayType="text" thousandSeparator="," suffix=" WICP" decimalScale={5} /> : `#${data?.tokenId}`; | ||
const secondaryDetail = iconHovered ? <NumberFormat value={data.price} displayType="text" thousandSeparator="," prefix="$" decimalScale={5} /> : 'Crowns'; | ||
return ( | ||
<> | ||
<ActivityItemDisplay | ||
image={( | ||
<div | ||
onMouseEnter={() => setIconHovered(true)} | ||
onMouseLeave={() => setIconHovered(false)} | ||
> | ||
<GenericIcon | ||
image={JellyIcon} | ||
type="JELLY" | ||
/> | ||
</div> | ||
)} | ||
title={data?.title} | ||
subtitle={moment(date).format('MMM Do')} | ||
/> | ||
<ActivityItemDetails | ||
main={mainDetail} | ||
secondary={secondaryDetail} | ||
hovering={hovering} | ||
details={details} | ||
setOpenDetail={setOpenDetail} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default JellyItem; | ||
|
||
JellyItem.defaultProps = { | ||
details: null, | ||
hovering: false, | ||
}; | ||
|
||
JellyItem.propTypes = { | ||
details: PropTypes.objectOf(PropTypes.string), | ||
date: PropTypes.oneOfType([ | ||
PropTypes.instanceOf(Date), | ||
PropTypes.string, | ||
]).isRequired, | ||
setOpenDetail: PropTypes.func.isRequired, | ||
hovering: PropTypes.bool, | ||
type: PropTypes.string.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1747,10 +1747,10 @@ | |
cross-fetch "^3.1.4" | ||
crypto-js "^4.1.1" | ||
|
||
"@psychedelic/[email protected].0": | ||
version "0.17.0" | ||
resolved "https://npm.pkg.github.com/download/@psychedelic/plug-controller/0.17.0/d0a7c716a95e32077cbab1e41507351f15073c1ba8747c5550024ee62ab88bcd#cf2a8b29275b56408ab79929c5b3b38f8bfac474" | ||
integrity sha512-c9c5TnB6fN0toCt8rzdlUwThPOSqcUrDRRRUYoemId2XHsmVqB2wCQbQKrq4u1HXYEXcmcCMqMt60qwNmbug2g== | ||
"@psychedelic/[email protected].2": | ||
version "0.17.2" | ||
resolved "https://npm.pkg.github.com/download/@psychedelic/plug-controller/0.17.2/9603a67bb3d798b7c54323654ab8f477505e42a43dc5b11f8f23ad126c5795c6#89a597ca104b5d1959aad3a444c6c088cd206309" | ||
integrity sha512-5nHVGu1qQZ4149WngxEf3Y5a00HWe3nm6Nv0ZY+Jy+VnmHUn31vSBsbDL0qbIcF+xdjpX/G0tjsUzV20DnbrsQ== | ||
dependencies: | ||
"@dfinity/agent" "0.9.3" | ||
"@dfinity/candid" "0.9.3" | ||
|
@@ -1779,10 +1779,10 @@ | |
text-encoding-shim "^1.0.5" | ||
tweetnacl "^1.0.3" | ||
|
||
"@psychedelic/[email protected].1": | ||
version "2.1.1" | ||
resolved "https://npm.pkg.github.com/download/@psychedelic/plug-inpage-provider/2.1.1/8fb073d7ee8cf970dc7f8d1d8577d360e928a1a9952d210c9bb78d1dd6111dc5#824c4c6999e3d81b9c2d9bb83ea6475b45326473" | ||
integrity sha512-kGR/ctFqQK2OlF/VIvWxNC93xPAM2+LXoKSyu4xA/N5FU8NX0ignmMtwmEAichGw/W2GlrL0MAEyYRxldffzew== | ||
"@psychedelic/[email protected].2": | ||
version "2.1.2" | ||
resolved "https://npm.pkg.github.com/download/@psychedelic/plug-inpage-provider/2.1.2/ad720049d164796d0de1cd513ea7423beaef59d2dffc26416c2006a935b272e2#7b42861b860758bb59fe1d6a080f6ed1f2e62964" | ||
integrity sha512-BsutLGWpIEYUw5Fz6vLKq1BjmTXzOKbstUrGBiIM/KtwQ9ralD5jMAOPkcLdQRxiZL0tE7VdnIKARBNNzenWIQ== | ||
dependencies: | ||
"@dfinity/agent" "0.9.3" | ||
"@dfinity/candid" "0.9.3" | ||
|