2021-02-11 13:30:29 +01:00
|
|
|
import React, { ReactElement } from 'react'
|
2021-04-13 10:57:59 +02:00
|
|
|
import { graphql, PageProps, useStaticQuery } from 'gatsby'
|
|
|
|
import Alert from './atoms/Alert'
|
2020-11-18 20:01:33 +01:00
|
|
|
import Footer from './organisms/Footer'
|
|
|
|
import Header from './organisms/Header'
|
|
|
|
import Styles from '../global/Styles'
|
2021-04-13 10:57:59 +02:00
|
|
|
import { useWeb3 } from '../providers/Web3'
|
2020-11-18 20:01:33 +01:00
|
|
|
import { useSiteMetadata } from '../hooks/useSiteMetadata'
|
2021-03-17 11:44:26 +01:00
|
|
|
import { useAccountPurgatory } from '../hooks/useAccountPurgatory'
|
2021-04-13 10:57:59 +02:00
|
|
|
import AnnouncementBanner from './atoms/AnnouncementBanner'
|
2021-05-27 14:01:20 +02:00
|
|
|
import styles from './App.module.css'
|
2021-10-12 10:00:57 +02:00
|
|
|
import PrivacyPreferenceCenter from './organisms/PrivacyPreferenceCenter'
|
2021-02-11 13:30:29 +01:00
|
|
|
|
2020-12-02 14:37:01 +01:00
|
|
|
const contentQuery = graphql`
|
|
|
|
query AppQuery {
|
|
|
|
purgatory: allFile(filter: { relativePath: { eq: "purgatory.json" } }) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
childContentJson {
|
|
|
|
account {
|
|
|
|
title
|
|
|
|
description
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2020-11-18 20:01:33 +01:00
|
|
|
|
|
|
|
export default function App({
|
|
|
|
children,
|
|
|
|
...props
|
|
|
|
}: {
|
|
|
|
children: ReactElement
|
|
|
|
}): ReactElement {
|
2020-12-02 14:37:01 +01:00
|
|
|
const data = useStaticQuery(contentQuery)
|
|
|
|
const purgatory = data.purgatory.edges[0].node.childContentJson.account
|
|
|
|
|
2021-10-12 10:00:57 +02:00
|
|
|
const { warning, appConfig } = useSiteMetadata()
|
2021-03-17 11:44:26 +01:00
|
|
|
const { accountId } = useWeb3()
|
|
|
|
const { isInPurgatory, purgatoryData } = useAccountPurgatory(accountId)
|
2020-11-18 20:01:33 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Styles>
|
|
|
|
<div className={styles.app}>
|
|
|
|
{(props as PageProps).uri === '/' && (
|
2021-06-09 12:49:00 +02:00
|
|
|
<AnnouncementBanner text={warning.main} />
|
2020-11-18 20:01:33 +01:00
|
|
|
)}
|
2021-06-09 12:49:00 +02:00
|
|
|
<Header />
|
2021-04-13 10:57:59 +02:00
|
|
|
|
2021-03-17 11:44:26 +01:00
|
|
|
{isInPurgatory && (
|
2020-11-18 20:01:33 +01:00
|
|
|
<Alert
|
2020-12-02 14:37:01 +01:00
|
|
|
title={purgatory.title}
|
2021-03-17 11:44:26 +01:00
|
|
|
badge={`Reason: ${purgatoryData?.reason}`}
|
2020-12-02 14:37:01 +01:00
|
|
|
text={purgatory.description}
|
2020-11-18 20:01:33 +01:00
|
|
|
state="error"
|
|
|
|
/>
|
|
|
|
)}
|
2021-02-11 13:30:29 +01:00
|
|
|
<main className={styles.main}>{children}</main>
|
2020-11-18 20:01:33 +01:00
|
|
|
<Footer />
|
2021-10-12 10:00:57 +02:00
|
|
|
|
|
|
|
{appConfig.privacyPreferenceCenter === 'true' && (
|
|
|
|
<PrivacyPreferenceCenter style="small" />
|
|
|
|
)}
|
2020-11-18 20:01:33 +01:00
|
|
|
</div>
|
|
|
|
</Styles>
|
|
|
|
)
|
|
|
|
}
|