-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trello 19 #31
base: master
Are you sure you want to change the base?
Trello 19 #31
Changes from 1 commit
a6f822b
c1262ba
bc3ad16
0a51551
e8dc5aa
ac912e7
a3f1135
6463125
ba28515
492fb9e
99f7eca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
|
||
interface TrackedChainProps { | ||
name: string; | ||
active: boolean; | ||
onClick: () => void; | ||
} | ||
|
||
const TrackedChain: React.FC<TrackedChainProps> = ({ name, active, onClick }) => { | ||
return ( | ||
<div | ||
className={`focus:outline-none py-4 capitalize cursor-pointer ${active ? 'font-bold text-primary' : ''}`} | ||
role="button" | ||
onClick={() => onClick()} | ||
onKeyPress={() => onClick()} | ||
tabIndex={0} | ||
> | ||
{name} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TrackedChain; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; | |
import { Card, CardBody, CardHeader } from '../../components/common'; | ||
import SearchInput from '../../components/common/Input'; | ||
import mockDataChain from './mock-data'; | ||
import TrackedChain from './TrackedChain'; | ||
|
||
type ChainType = 'evm' | 'substrate'; | ||
|
||
|
@@ -28,38 +29,15 @@ const TrackedContractsList: React.FC<{}> = () => { | |
setChains(mockDataChain as Chain[]); | ||
}, []); | ||
|
||
// Filter out by the search but also keep the current active in the search | ||
const allChains = chains | ||
.filter((data) => { | ||
if (!searchChain) { | ||
return data; | ||
} | ||
if (data.name.includes(searchChain.trim().toLocaleLowerCase())) { | ||
return data; | ||
} | ||
return null; | ||
}) | ||
.map((chain) => { | ||
return ( | ||
<div | ||
className={`focus:outline-none py-4 capitalize cursor-pointer ${ | ||
chain.name === activeChain?.name ? 'font-bold text-primary' : '' | ||
}`} | ||
role="button" | ||
onClick={() => setActiveChain(chain)} | ||
onKeyPress={() => setActiveChain(chain)} | ||
tabIndex={0} | ||
> | ||
{chain.name} | ||
</div> | ||
); | ||
}); | ||
.filter((chain) => chain.name.includes(searchChain.trim().toLocaleLowerCase()) || activeChain?.name === chain.name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just this filter works actually no need to check for if defined or null. Also added the fact that if a chan is already active you might still want to see it despite searching |
||
.map((chain) => ( | ||
<TrackedChain active={chain.name === activeChain?.name} name={chain.name} onClick={() => setActiveChain(chain)} /> | ||
)); | ||
|
||
const activeContracts = | ||
activeChain && activeChain.tracked_contracts.length | ||
? activeChain.tracked_contracts.map((contract) => { | ||
return contract; | ||
}) | ||
: 'No Tracked Contracts'; | ||
activeChain && activeChain.tracked_contracts.length ? activeChain.tracked_contracts : 'No Tracked Contracts'; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should also work
|
||
return ( | ||
<div className="container mx-auto"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it here, in the same folder, I don't think it's gonna be used anywhere else so no need to put it inside components