Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
feat(Donations): link to ContributorsPage from DonatePage
Browse files Browse the repository at this point in the history
  • Loading branch information
CanRau committed Dec 1, 2018
1 parent 359d8dd commit 05f7e60
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions src/templates/DonatePage.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'gatsby'
import { graphql, Link } from 'gatsby'
import Img from 'gatsby-image'
import { media } from '@/theme'
import MainLayout from '@/components/MainLayout'
import TitledCopy from '@/components/TitledCopy'
import { SupportWidget } from '@/components/Shared'

const calcTotalAmount = x =>
x.edges.reduce((acc, val) => acc + val.node.amount, 0)

const DonatePage = props => {
const { page } = props.data
const { page, contributions } = props.data
return (
<MainLayout {...props}>
<div
Expand All @@ -30,22 +32,33 @@ const DonatePage = props => {
margin: 2rem auto 0;
${media.greaterThan(`medium`)} {
margin-right: 1rem;
max-width: 60%;
max-width: 56%;
}
`}
/>

<div>
<h1>{page.frontmatter.intro.title}</h1>
{page.frontmatter.intro.text.map(x => (
<div
key={x}
dangerouslySetInnerHTML={{ __html: x }}
css={`
line-height: 1.8rem;
`}
/>
))}
<div>
{page.frontmatter.intro.text.map(x => (
<div
key={x}
dangerouslySetInnerHTML={{ __html: x }}
css={`
line-height: 1.8rem;
`}
/>
))}
</div>
<div
css={`
margin-top: 1rem;
`}
>
Thanks to our <Link to="/en/contributors">supporters</Link> for
donating {calcTotalAmount(contributions)}
</div>
</div>
</div>

Expand All @@ -68,6 +81,7 @@ const DonatePage = props => {
DonatePage.propTypes = {
data: PropTypes.shape({
page: PropTypes.object,
contributions: PropTypes.object,
SiteMeta: PropTypes.object,
SupportWidget: PropTypes.object,
}),
Expand All @@ -76,7 +90,7 @@ DonatePage.propTypes = {
export default DonatePage

export const query = graphql`
query($lang: String!, $slug: String!) {
query($lang: String!, $url: String!) {
...siteData
...SiteMeta
...languages
Expand All @@ -86,7 +100,7 @@ export const query = graphql`
...Accounts
...SupportWidget
page: javascriptFrontmatter(frontmatter: { slug: { eq: $slug } }) {
page: javascriptFrontmatter(fields: { url: { eq: $url } }) {
...PageTranslations
fields {
url
Expand All @@ -111,5 +125,13 @@ export const query = graphql`
}
}
}
contributions: allPayPalJson {
edges {
node {
amount
}
}
}
}
`

0 comments on commit 05f7e60

Please sign in to comment.