Skip to content

Commit

Permalink
fix(components): update history component for new activity types
Browse files Browse the repository at this point in the history
  • Loading branch information
AshenI99 committed Mar 24, 2022
1 parent 14b69c3 commit 436daa0
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 30 deletions.
53 changes: 44 additions & 9 deletions packages/components/src/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import moment from "moment";
type historyProps = {
type: string
timestamp: string
mintBy?: { id : string | null } | null
burnBy?: { id : string | null } | null
bidBy?: { id : string | null } | null
transferFrom?: { id : string | null } | null
transferTo?: { id : string | null } | null
amount: number | null
sender?: { id : string | null } | null
recipient?: { id : string | null } | null
transactionHash: string
}

Expand Down Expand Up @@ -85,6 +83,37 @@ function Bid({ accountId } : { accountId : string }){
)
}

function BidRemove({ accountId } : { accountId : string }){
return(
<Box>
<Link href={`https://explorer.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> removed their bid.
</Box>
)
}

function BidAccept({ accountId, receiverId } : { accountId : string, receiverId: string }){
return(
<Box>
<Link href={`https://explorer.near.org/accounts/${accountId}`} target={"_blank"}>
{accountId}
</Link> accepted{" "}
<Link href={`https://explorer.near.org/accounts/${receiverId}`} target={"_blank"}>
{ receiverId }
</Link>
's bid.
</Box>
)
}

function BidUpdate({ accountId } : { accountId : string }){
return(
<Box>
<Link href={`https://explorer.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> updated their bid.
</Box>
)
}


function Transfer({ accountId, receiverId } : { accountId : string, receiverId: string }){
return(
<Box>
Expand Down Expand Up @@ -124,10 +153,16 @@ export function History ({ history = [] } : {
transactionHash={ historyItem.transactionHash }
>
<>
{historyItem.type == "burn" && <Burn accountId = {historyItem.burnBy!.id! }/> }
{historyItem.type == "mint" && <Mint accountId = {historyItem.mintBy!.id! }/> }
{historyItem.type == "bid" && <Bid accountId = {historyItem.bidBy!.id! }/> }
{historyItem.type == "transfer" && <Transfer accountId = {historyItem.transferFrom!.id! } receiverId={ historyItem.transferTo!.id! } /> }
{historyItem.type == "burn" && <Burn accountId = {historyItem.sender!.id! }/> }
{historyItem.type == "mint" && <Mint accountId = {historyItem.sender!.id! }/> }
{historyItem.type == "set_bid" && <Bid accountId = {historyItem.sender!.id! }/> }
<<<<<<< HEAD
{historyItem.type == "remove_bid" && <BidRemove accountId = {historyItem.sender!.id! }/> }
{historyItem.type == "accept_bid" && <BidAccept accountId = {historyItem.sender!.id! } receiverId={ historyItem.recipient!.id! }/> }
{historyItem.type == "update_bid" && <BidUpdate accountId = {historyItem.sender!.id! }/> }
=======
>>>>>>> 0885e3cd3d2d2352c88ddfc67425194d6cd8c86c
{historyItem.type == "transfer" && <Transfer accountId = {historyItem.sender!.id! } receiverId={ historyItem.recipient!.id! } /> }
</>
</HistoryItemLayout>
)
Expand Down
55 changes: 34 additions & 21 deletions packages/components/src/stories/History.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,51 @@ Tre.args = {
{
type: "mint",
timestamp: "1641199188285678087",
mintBy: { id: "demo.testnet" },
burnBy: null,
bidBy: null,
transferFrom: null,
transferTo: null,
sender: { id: "demo.testnet" },
amount: null,
recipient: null,
transactionHash: "aayyx44578ggnkk98989787fbjby8"
}, {
type: "bid",
type: "set_bid",
timestamp: "1649199188285678087",
mintBy: null,
burnBy: null,
bidBy: { id: "demo.testnet" },
transferFrom: null,
transferTo: null,
sender: { id: "demo.testnet" },
amount: null,
recipient: null,
transactionHash: "aayyx44578FFFbb5654fbjby8"
}, {
type: "remove_bid",
timestamp: "1649199188285678087",
sender: { id: "demo.testnet" },
amount: null,
recipient: null,
transactionHash: "aayyx44578FFFbb5654fbjby8"
}, {
type: "update_bid",
timestamp: "1649199188285678087",
sender: { id: "demo.testnet" },
amount: null,
recipient: null,
transactionHash: "aayyx44578FFFbb5654fbjby8"
}, {
type: "accept_bid",
timestamp: "1649199188285678087",
sender: { id: "demo.testnet" },
amount: null,
recipient: {id : "demo2.testnet" },
transactionHash: "aayyx44578FFFbb5654fbjby8"
},{
type: "burn",
timestamp: "1642599168285678017",
mintBy: null,
burnBy: { id: "demo.testnet" },
bidBy: null,
transferFrom: null,
transferTo: null,
sender: { id: "demo.testnet" },
amount: null,
recipient: null,
transactionHash: "aayyx44578gg4666h583vvnkk98989787fbjby8"
}, {
type: "transfer",
timestamp: "1642199908285679017",
mintBy: null,
burnBy: null,
bidBy: null,
transferFrom: { id: "demo.testnet" },
transferTo: {id : "demo2.testnet" },
sender: { id: "demo.testnet" },
recipient: {id : "demo2.testnet" },
amount: null,
transactionHash: "aadddJhjdB7889HUu?78dvfn89787fbjby8"
}
]
Expand Down

0 comments on commit 436daa0

Please sign in to comment.