-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tien Nam Dao
committed
Nov 17, 2022
1 parent
87e2f0a
commit 9739a6a
Showing
14 changed files
with
431 additions
and
27 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
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
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,29 @@ | ||
import BackgroundCard from 'components/Card/Background/BackgroundCard' | ||
import Tabs from 'components/Tabs/Tabs' | ||
import useRouterTag from 'hooks/useRouterTag' | ||
import NftTransferTab from './tabs/NftTransfers' | ||
|
||
interface Props { | ||
token: string | ||
tokenData: TokenNFTMetadata | ||
} | ||
|
||
const NftDetailTab = ({ token, tokenData }: Props) => { | ||
const [defaultTag, setTag] = useRouterTag() | ||
|
||
return ( | ||
<BackgroundCard classes="margin-top-lg padding-bottom-lg"> | ||
<Tabs | ||
tabChange={setTag} | ||
defaultTab={defaultTag} | ||
classes="none" | ||
tabs={[{ title: 'Token Transfers', id: 'token-transfers' }]} | ||
contents={{ | ||
'token-transfers': <NftTransferTab token={token} tokenData={tokenData} /> | ||
}} | ||
></Tabs> | ||
</BackgroundCard> | ||
) | ||
} | ||
|
||
export default NftDetailTab |
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,39 @@ | ||
import BackgroundCard from 'components/Card/Background/BackgroundCard' | ||
import Row from 'components/Grid/Row' | ||
import Image from 'next/image' | ||
|
||
interface Props { | ||
token: string | ||
tokenId: string | ||
tokenData: TokenNFTMetadata | ||
} | ||
|
||
const NftOverview = ({ token, tokenData, tokenId }: Props) => { | ||
const tokenImage = tokenData?.image.replace('ipfs://', 'https://ipfs.io/ipfs/') | ||
return ( | ||
<BackgroundCard classes="padding-top-lg padding-bottom-lg margin-top-2xl padding-left-2xl padding-right-2xl"> | ||
<Row> | ||
<div className="col-6 margin-right-md"> | ||
<Row style={{ justifyContent: 'space-between' }}> | ||
<span className="text text-base contrast-color-50">Token ID:</span> | ||
<span className="text text-base">{tokenId}</span> | ||
</Row> | ||
<Row style={{ justifyContent: 'space-between' }}> | ||
<span className="text text-base contrast-color-50">Name:</span> | ||
<span className="text text-base">{tokenData.name}</span> | ||
</Row> | ||
|
||
<Row style={{ justifyContent: 'space-between' }}> | ||
<span className="text text-base contrast-color-50">Description:</span> | ||
<span className="text text-base">{tokenData.description}</span> | ||
</Row> | ||
</div> | ||
<div className="col-6 flex flex-justify-end"> | ||
<Image src={tokenImage} alt={tokenData.name} height={100} width={120} layout="fixed" /> | ||
</div> | ||
</Row> | ||
</BackgroundCard> | ||
) | ||
} | ||
|
||
export default NftOverview |
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,68 @@ | ||
import API_LIST from 'api/api_list' | ||
import { useEffect, useState } from 'react' | ||
import useSWR from 'swr' | ||
import { ZERO_ADDRESS } from 'utils/constants' | ||
import { getEnvNumber } from 'utils/helper' | ||
|
||
/** | ||
* @todo: Not implement yet | ||
* @param token | ||
* @param params | ||
* @returns | ||
*/ | ||
export default function useNftTransfer(token: string, params: string | undefined): UseTokenTransactionHookData { | ||
const [hookData, setState] = useState({ | ||
result: [], | ||
hasNextPage: false, | ||
nextPagePath: undefined | ||
}) | ||
|
||
const _fetchCondition = () => { | ||
if (params) { | ||
return [ | ||
`${API_LIST.TOKEN_TRANSACTIONS}${params}`, | ||
{ | ||
contractaddress: token | ||
} | ||
] | ||
} | ||
|
||
return [ | ||
API_LIST.TOKEN_TRANSACTIONS, | ||
{ | ||
contractaddress: token, | ||
page: 1, | ||
offset: getEnvNumber('NEXT_PUBLIC_PAGE_OFFSET') | ||
} | ||
] | ||
} | ||
const { data } = useSWR<TokenTransactionResponse>(_fetchCondition()) | ||
|
||
const convertData = (_data: TokenTransactionResponse): TokenTransaction[] => { | ||
return data.result.map((d: TokenTransaction) => { | ||
const isMint = d.fromAddress === ZERO_ADDRESS | ||
const isBurn = d.toAddress === ZERO_ADDRESS | ||
|
||
return { | ||
...d, | ||
type: d.type || (isMint && 'Mint') || (isBurn && 'Burn') | ||
} | ||
}) | ||
} | ||
|
||
useEffect(() => { | ||
if (data?.result) { | ||
setState({ | ||
result: convertData(data), | ||
hasNextPage: data.hasNextPage, | ||
nextPagePath: data.nextPagePath | ||
}) | ||
} | ||
}, [data]) | ||
|
||
return { | ||
result: hookData.result, | ||
hasNextPage: hookData.hasNextPage, | ||
nextPagePath: hookData.nextPagePath | ||
} | ||
} |
Oops, something went wrong.