Skip to content
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

Ts migration(src/pages): Migrated assigned files #6829

Merged
merged 21 commits into from
Jul 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d07548e
Feat(pages/404): Migrated 404.js => 404.tsx
M-Ivan Jun 26, 2022
564cb30
Fix(pages/404): Removed unnecessary round branckets string on 404 page
M-Ivan Jun 26, 2022
7e48a05
Feat(pages/404): Created interface for props and solved type errors
M-Ivan Jun 26, 2022
b7b59a1
Feat(pages/bug-bounty): Created interfaces for the page and improved …
M-Ivan Jun 26, 2022
f8dd080
Feat(pages/community): Community.js => Community.tsx
M-Ivan Jun 26, 2022
a0929e9
Feat(pages/community): Created interfaces for the community hub page
M-Ivan Jun 26, 2022
8c8d376
Fix(git): Merged branch 'dev' into base and solved conflicts
M-Ivan Jul 9, 2022
f8de08a
Fix(bug-bounty): Fixed the declaration of page props and the sort met…
M-Ivan Jul 9, 2022
06bfd9c
Fix(404): Fixed props definition
M-Ivan Jul 9, 2022
2cd06cd
Fix(assets): Fixed the props definition to use PageProps
M-Ivan Jul 9, 2022
556ece2
Fix(assets): Fixed props definition and removed unnecessary GetImage …
M-Ivan Jul 9, 2022
ab44844
Fix(community): Fixed props definition, array type declaration and re…
M-Ivan Jul 9, 2022
9c23674
Fix(bug-bounty): Removed unnecessary export statements
M-Ivan Jul 9, 2022
71c5447
Fix(404): Added extra space
M-Ivan Jul 10, 2022
f790f8b
Merge branch 'dev' into review-ivan2
pettinarip Jul 14, 2022
a7c1f76
revert changes on md files
pettinarip Jul 14, 2022
9ac4c16
simplify typing in assetdownload component
pettinarip Jul 14, 2022
aec7503
minor fixes on types
pettinarip Jul 15, 2022
e6a7b4e
Merge branch 'dev' into review-ivan2
pettinarip Jul 15, 2022
ecf33ad
call getImage on header image
pettinarip Jul 15, 2022
596c351
Merge branch 'dev' into review-ivan2
pettinarip Jul 16, 2022
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
2 changes: 1 addition & 1 deletion src/components/AssetDownload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface IPropsWithSVG extends IPropsBase {
}
interface IPropsWithImage extends IPropsBase {
svg?: never
image: string
image: any
}

export type IProps = IPropsWithImage | IPropsWithSVG
Expand Down
2 changes: 1 addition & 1 deletion src/components/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const githubUrl = `https://github.com/`

export interface Person {
name: string
username: string
username?: string
score: number
}

Expand Down
3 changes: 2 additions & 1 deletion src/pages/404.js → src/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import Link from "../components/Link"
import Translation from "../components/Translation"

import { Page, Content } from "../components/SharedStyledComponents"
import { PageProps } from "gatsby"

const StyledPage = styled(Page)`
margin-top: 4rem;
`

const NotFoundPage = () => (
const NotFoundPage = (props: PageProps) => (
<StyledPage>
<Content>
<h1>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/assets.js → src/pages/assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useIntl } from "react-intl"
import { ThemeContext } from "styled-components"
import styled from "styled-components"
import { GatsbyImage, getImage } from "gatsby-plugin-image"
import { graphql } from "gatsby"
import { graphql, PageProps } from "gatsby"

import AssetDownload from "../components/AssetDownload"
import Link from "../components/Link"
Expand All @@ -14,6 +14,7 @@ import FeedbackCard from "../components/FeedbackCard"

import { translateMessageId } from "../utils/translations"
import EthGlyphColoredSvg from "../assets/assets/eth-glyph-colored.svg"
import { Context } from "../types"

const Image = styled(GatsbyImage)`
align-self: center;
Expand Down Expand Up @@ -75,7 +76,7 @@ const Header = styled.header`
}
`

const AssetsPage = ({ data }) => {
const AssetsPage = ({ data }: PageProps<Queries.AssetsPageQuery, Context>) => {
const intl = useIntl()
const themeContext = useContext(ThemeContext)
const isDarkTheme = themeContext.isDark
Expand Down
106 changes: 75 additions & 31 deletions src/pages/bug-bounty.js → src/pages/bug-bounty.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useContext } from "react"
import React, { ReactNode, useContext } from "react"
import { ThemeContext } from "styled-components"
import styled from "styled-components"
import { GatsbyImage, getImage } from "gatsby-plugin-image"
import { graphql } from "gatsby"
import { graphql, PageProps } from "gatsby"
import { useIntl } from "react-intl"

import { translateMessageId } from "../utils/translations"
Expand All @@ -27,6 +27,7 @@ import {
SloganGradient,
} from "../components/SharedStyledComponents"
import FeedbackCard from "../components/FeedbackCard"
import { Context } from "../types"

const HeroCard = styled.div`
display: flex;
Expand Down Expand Up @@ -230,44 +231,87 @@ const Faq = styled.div`
}
`

const BugBountiesPage = ({ data, location }) => {
type BountyHuntersArg = {
score?: number | null
}

function sortBountyHuntersFn(a: BountyHuntersArg, b: BountyHuntersArg) {
if (a.score && b.score) {
return b.score - a.score
}

return 0
}

interface INode {
readonly username: string
readonly name: string
readonly score: number
}

interface IClient {
title: string
link: string
image: any
}

interface ISpec {
title: ReactNode
link: string
}

const BugBountiesPage = ({
data,
location,
}: PageProps<Queries.BugBountyPageQuery, Context>) => {
const intl = useIntl()
const themeContext = useContext(ThemeContext)
const isDarkTheme = themeContext.isDark

// TODO sort query isn't working :(
const consensusBountyHunters = data.consensusBountyHunters.nodes.sort(
(a, b) => b.score - a.score
const consensusBountyHuntersNodes = data.consensusBountyHunters
.nodes as Array<INode>
const consensusBountyHunters = [...consensusBountyHuntersNodes].sort(
sortBountyHuntersFn
)

const executionBountyHunters = data.executionBountyHunters.nodes.sort(
(a, b) => b.score - a.score
const executionBountyHuntersNodes = data.executionBountyHunters
.nodes as Array<INode>
const executionBountyHunters = [...executionBountyHuntersNodes].sort(
sortBountyHuntersFn
)

const bountyHuntersArrayToObject: Record<string, INode> = [
...consensusBountyHunters,
...executionBountyHunters,
].reduce((acc, next) => {
const name = next.name
if (!name) {
return acc
}

if (acc[name]) {
return {
...acc,
[name]: {
...next,
score: acc[name].score + next.score,
},
}
}

return {
...acc,
[name]: next,
}
}, {})

// total all counts using name as identifier, then sort
const allBounterHunters = Object.values(
[...consensusBountyHunters, ...executionBountyHunters].reduce(
(acc, next) => {
if (acc[next.name]) {
return {
...acc,
[next.name]: {
...next,
score: acc[next.name].score + next.score,
},
}
}

return {
...acc,
[next.name]: next,
}
},
{}
)
).sort((a, b) => b.score - a.score)

const clients = [
const allBounterHunters = Object.values(bountyHuntersArrayToObject).sort(
(a, b) => b.score - a.score
)

const clients: Array<IClient> = [
{
title: "Besu",
link: "https://besu.hyperledger.org/en/stable/",
Expand Down Expand Up @@ -327,7 +371,7 @@ const BugBountiesPage = ({ data, location }) => {
? getImage(data.lighthouseDark)
: getImage(data.lighthouseLight)

const specs = [
const specs: Array<ISpec> = [
{
title: <Translation id="page-upgrades-bug-bounty-title-1" />,
link: "https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md",
Expand Down
25 changes: 21 additions & 4 deletions src/pages/community.js → src/pages/community.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import styled from "styled-components"
import { GatsbyImage, getImage } from "gatsby-plugin-image"
import { graphql } from "gatsby"
import { graphql, PageProps } from "gatsby"
import { useIntl } from "react-intl"

import ActionCard from "../components/ActionCard"
Expand All @@ -21,6 +21,7 @@ import {
Page,
} from "../components/SharedStyledComponents"
import { translateMessageId } from "../utils/translations"
import { Context } from "../types"

const ButtonRow = styled.div`
display: flex;
Expand Down Expand Up @@ -306,7 +307,23 @@ const StyledCallout = styled(Callout)`
min-height: 100%;
`

const CommunityPage = ({ data }) => {
interface ICard {
image: any
title: string
description: string
alt: string
to: string
}

interface IGetInvolvedCard {
emoji: string
title: string
description: string
}

const CommunityPage = ({
data,
}: PageProps<Queries.CommunityPageQuery, Context>) => {
const intl = useIntl()

const heroContent = {
Expand All @@ -317,7 +334,7 @@ const CommunityPage = ({ data }) => {
alt: translateMessageId("page-community-hero-alt", intl),
}

const cards = [
const cards: Array<ICard> = [
{
image: getImage(data.docking),
title: translateMessageId("page-community-card-1-title", intl),
Expand Down Expand Up @@ -360,7 +377,7 @@ const CommunityPage = ({ data }) => {
},
]

const whyGetInvolvedCards = [
const whyGetInvolvedCards: Array<IGetInvolvedCard> = [
{
emoji: ":mage:",
title: translateMessageId(
Expand Down