-
Notifications
You must be signed in to change notification settings - Fork 51
feat: jurors page #1840
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
Merged
Merged
feat: jurors page #1840
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ed63810
feat: initial jurors page setup, jurors explore navlink, small stylin…
kemuru 1b22294
feat: filter by totalresolvedvotes bigger than 0, types fix
kemuru 63c308b
fix: subgraph bug which has not counting missed votes
kemuru ac069a3
Merge branch 'dev' into feat(web)/jurors-page
kemuru 118feb6
Merge branch 'dev' into feat(web)/jurors-page
kemuru af51757
Merge branch 'dev' into feat(web)/jurors-page
kemuru db29a3d
feat: myprofile links, subgraph changes, pagination, query optimizati…
kemuru c95ee8a
Merge branch 'dev' into feat(web)/jurors-page
kemuru f2867a2
feat: add subgraph field, ranking icon, fix extra stats bug, filters,…
kemuru c749b2d
fix: nitpick text change
kemuru 132743a
chore: add arrow back into the accordiontitle
kemuru 07f83fa
chore: layout improvement
kemuru 94c7637
fix: search to lower case in query
kemuru 22e54d7
chore: move coherence percent function to utils, change name for clarity
kemuru 81a3412
fix: layout shift if there is no rank, hide pagination if searching
kemuru b5d969b
Merge branch 'dev' into feat(web)/jurors-page
kemuru 535508a
fix: few code smells
kemuru d04f0e1
chore: change label in mobile if search is active
kemuru 876e208
Merge branch 'dev' into feat(web)/jurors-page
alcercu e6875eb
chore: subgraphs redeploy, scripts tweaks
jaybuidl 2bb0a19
chore: txt
kemuru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,76 @@ | ||
import React, { useRef, useState } from "react"; | ||
import styled, { css } from "styled-components"; | ||
|
||
import { useNavigate, useParams, useSearchParams } from "react-router-dom"; | ||
import { useDebounce } from "react-use"; | ||
import { Searchbar } from "@kleros/ui-components-library"; | ||
|
||
import { isEmpty } from "utils/index"; | ||
import { decodeURIFilter, encodeURIFilter, useRootPath } from "utils/uri"; | ||
|
||
import { landscapeStyle } from "styles/landscapeStyle"; | ||
import { responsiveSize } from "styles/responsiveSize"; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: ${responsiveSize(8, 16)}; | ||
|
||
${landscapeStyle( | ||
() => css` | ||
flex-direction: row; | ||
` | ||
)} | ||
`; | ||
|
||
const StyledSearchbar = styled(Searchbar)` | ||
flex: 1; | ||
flex-basis: 310px; | ||
|
||
input { | ||
font-size: 16px; | ||
height: 45px; | ||
padding-top: 0px; | ||
padding-bottom: 0px; | ||
} | ||
`; | ||
|
||
const Search: React.FC = () => { | ||
const { page, order, filter } = useParams(); | ||
const location = useRootPath(); | ||
const decodedFilter = decodeURIFilter(filter ?? "all"); | ||
const { id: searchValue, ...filterObject } = decodedFilter; | ||
const [search, setSearch] = useState(searchValue ?? ""); | ||
const initialRenderRef = useRef(true); | ||
const navigate = useNavigate(); | ||
const [searchParams] = useSearchParams(); | ||
|
||
useDebounce( | ||
() => { | ||
if (initialRenderRef.current && isEmpty(search)) { | ||
initialRenderRef.current = false; | ||
return; | ||
} | ||
initialRenderRef.current = false; | ||
const newFilters = isEmpty(search) ? { ...filterObject } : { ...filterObject, id: search }; | ||
const encodedFilter = encodeURIFilter(newFilters); | ||
navigate(`${location}/${page}/${order}/${encodedFilter}?${searchParams.toString()}`); | ||
}, | ||
500, | ||
[search] | ||
); | ||
kemuru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<Container> | ||
<StyledSearchbar | ||
dir="auto" | ||
type="text" | ||
placeholder="Search" | ||
value={search} | ||
onChange={(e) => setSearch(e.target.value)} | ||
/> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Search; |
This file contains hidden or 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,28 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
const FieldWrapper = styled.div` | ||
display: inline-flex; | ||
gap: 8px; | ||
`; | ||
|
||
const StyledLabel = styled.label` | ||
color: ${({ theme }) => theme.primaryText}; | ||
`; | ||
|
||
const Field: React.FC<{ label: string; value: string }> = ({ label, value }) => ( | ||
<FieldWrapper> | ||
<StyledLabel>{label}</StyledLabel> | ||
<small>{value}</small> | ||
</FieldWrapper> | ||
); | ||
|
||
export interface IStats { | ||
totalJurors: number; | ||
} | ||
|
||
const Stats: React.FC<IStats> = ({ totalJurors }) => { | ||
return <Field label="Total" value={`${totalJurors} Jurors`} />; | ||
}; | ||
|
||
export default Stats; |
This file contains hidden or 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,22 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
import { responsiveSize } from "styles/responsiveSize"; | ||
import Stats, { IStats } from "./Stats"; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 8px; | ||
margin-top: ${responsiveSize(4, 8)}; | ||
margin-bottom: ${responsiveSize(16, 32)}; | ||
justify-content: space-between; | ||
`; | ||
|
||
const StatsAndFilters: React.FC<IStats> = ({ totalJurors }) => ( | ||
<Container> | ||
<Stats {...{ totalJurors }} /> | ||
</Container> | ||
); | ||
|
||
export default StatsAndFilters; |
This file contains hidden or 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,65 @@ | ||
import React from "react"; | ||
import styled, { css } from "styled-components"; | ||
|
||
import { MAX_WIDTH_LANDSCAPE, landscapeStyle } from "styles/landscapeStyle"; | ||
import { responsiveSize } from "styles/responsiveSize"; | ||
|
||
import { isUndefined } from "utils/index"; | ||
|
||
import { useTopUsersByCoherenceScore } from "queries/useTopUsersByCoherenceScore"; | ||
|
||
import { SkeletonDisputeListItem } from "components/StyledSkeleton"; | ||
import Search from "./Search"; | ||
import StatsAndFilters from "./StatsAndFilters"; | ||
import JurorCard from "../Home/TopJurors/JurorCard"; | ||
import { ListContainer, StyledLabel } from "../Home/TopJurors"; | ||
import Header from "../Home/TopJurors/Header"; | ||
|
||
const Container = styled.div` | ||
width: 100%; | ||
background-color: ${({ theme }) => theme.lightBackground}; | ||
padding: 32px 16px 40px; | ||
max-width: ${MAX_WIDTH_LANDSCAPE}; | ||
margin: 0 auto; | ||
|
||
${landscapeStyle( | ||
() => css` | ||
padding: 48px ${responsiveSize(0, 132)} 60px; | ||
` | ||
)} | ||
`; | ||
|
||
const StyledTitle = styled.h1` | ||
margin: 0px; | ||
font-size: ${responsiveSize(20, 24)}; | ||
`; | ||
|
||
const Jurors: React.FC = () => { | ||
const { data: queryJurors } = useTopUsersByCoherenceScore(1000); | ||
|
||
const topJurors = queryJurors?.users?.map((juror, index) => ({ | ||
...juror, | ||
rank: index + 1, | ||
})); | ||
|
||
return ( | ||
<Container> | ||
<StyledTitle>Jurors Leaderboard</StyledTitle> | ||
<Search /> | ||
<StatsAndFilters totalJurors={0} /> | ||
|
||
{!isUndefined(topJurors) && topJurors.length === 0 ? ( | ||
<StyledLabel>There are no jurors staked yet.</StyledLabel> | ||
) : ( | ||
<ListContainer> | ||
<Header /> | ||
{!isUndefined(topJurors) | ||
? topJurors.map((juror) => <JurorCard key={juror.rank} address={juror.id} {...juror} />) | ||
: [...Array(5)].map((_, i) => <SkeletonDisputeListItem key={i} />)} | ||
</ListContainer> | ||
kemuru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
)} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Jurors; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.