Skip to content

Commit

Permalink
feat(web): pass real info to the tweet
Browse files Browse the repository at this point in the history
  • Loading branch information
kemuru committed Oct 30, 2023
1 parent 78b0fd6 commit a15a07c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions web/src/pages/Dashboard/JurorInfo/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ const StyledLink = styled.a`
}
`;

const Header: React.FC = () => {
interface IHeader {
levelTitle: string;
levelNumber: number;
totalCoherent: number;
totalResolvedDisputes: number;
}

const Header: React.FC<IHeader> = ({ levelTitle, levelNumber, totalCoherent, totalResolvedDisputes }) => {
const coherencePercentage = parseFloat(((totalCoherent / Math.max(totalResolvedDisputes, 1)) * 100).toFixed(2));
const courtUrl = window.location.origin;
const xPostText = `Hey I've been busy as a Juror on the Kleros court, check out my score: Level: 2 (Diogenes). Coherence score: 8. Be a juror with me -> ${courtUrl}`;
const xPostText = `Hey I've been busy as a Juror on the Kleros court, check out my score: \n\nLevel: ${levelNumber} (${levelTitle})\nCoherent Votes: ${totalCoherent}/${totalResolvedDisputes}\nCoherence Percentage: ${coherencePercentage}%\n\nBe a juror with me -> ${courtUrl}`;
const xShareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(xPostText)}`;

return (
Expand Down
7 changes: 6 additions & 1 deletion web/src/pages/Dashboard/JurorInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ const JurorInfo: React.FC = () => {

return (
<Container>
<Header />
<Header
levelTitle={userLevelData.title}
levelNumber={userLevelData.level}
totalCoherent={totalCoherent}
totalResolvedDisputes={totalResolvedDisputes}
/>
<Card>
<PixelArt level={userLevelData.level} width="189px" height="189px" />
<Coherency
Expand Down

0 comments on commit a15a07c

Please sign in to comment.