Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions frontend/packages/client/src/components/LeaderBoard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Web3Consumer } from 'contexts/Web3';
import React from 'react';
import Blockies from 'react-blockies';
import classnames from 'classnames';
import { WrapperResponsive } from '../components';
import { useLeaderBoard } from '../hooks';

Expand Down Expand Up @@ -28,6 +29,9 @@ const LeaderBoard = ({
const { user } = web3;
const { data, isLoading } = useLeaderBoard({ communityId, addr: user?.addr });
const style = {};
const currentUserInLeaderboard = data?.users?.some(
(datum) => datum.addr === user?.addr
);

return (
<div className="is-flex is-flex-direction-column">
Expand All @@ -43,17 +47,19 @@ const LeaderBoard = ({
{!isLoading &&
data?.users.map((datum, index) => {
const userIndex = index + 1;
const styleIndex =
index === 0
? 'rounded-sm-tl has-background-white-ter index-cell'
: index === 4
? 'rounded-sm-bl has-background-white-ter index-cell'
: 'has-background-white-ter index-cell';
const indexClasses = classnames({
'index-cell': index === 0 || index === 4,
'rounded-sm-tl': index === 0,
'rounded-sm-bl': index === 4,
'has-background-white-ter': !currentUserInLeaderboard,
'has-background-black-bis': currentUserInLeaderboard,
'has-text-white': currentUserInLeaderboard,
});

return (
<Row
key={`row-table-${index}`}
classNameIndex={styleIndex}
classNameIndex={indexClasses}
index={
<div className="smaller-text has-text-weight-bold">
{userIndex}
Expand All @@ -80,7 +86,7 @@ const LeaderBoard = ({
})}
</tbody>
</table>
{!isLoading && data?.currentUser && (
{!isLoading && data?.currentUser && !currentUserInLeaderboard && (
<table className="table is-fullwidth">
<tbody className="is-scrollable-table" style={style}>
<Row
Expand Down