stacker.news/pages/_app.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-04-14 00:57:32 +00:00
import '../styles/globals.scss'
2021-10-26 20:49:37 +00:00
import { ApolloProvider, gql } from '@apollo/client'
2021-04-12 18:05:09 +00:00
import { Provider } from 'next-auth/client'
2021-05-20 21:32:59 +00:00
import { FundErrorModal, FundErrorProvider } from '../components/fund-error'
2021-11-09 17:38:58 +00:00
import { MeProvider } from '../components/me'
2021-07-15 20:49:13 +00:00
import PlausibleProvider from 'next-plausible'
import { LightningProvider } from '../components/lightning'
2021-09-10 18:55:36 +00:00
import { ItemActModal, ItemActProvider } from '../components/item-act'
2021-09-30 15:46:58 +00:00
import getApolloClient from '../lib/apollo'
2021-11-13 13:28:08 +00:00
import NextNProgress from 'nextjs-progressbar'
2021-11-28 17:29:17 +00:00
import { PriceProvider } from '../components/price'
2021-03-22 20:36:10 +00:00
2021-09-30 15:46:58 +00:00
function MyApp ({ Component, pageProps: { session, ...props } }) {
2021-10-26 20:49:37 +00:00
const client = getApolloClient()
2021-11-09 22:43:56 +00:00
2021-10-26 20:49:37 +00:00
/*
If we are on the client, we populate the apollo cache with the
ssr data
*/
if (typeof window !== 'undefined') {
const { apollo, data } = props
if (apollo) {
client.writeQuery({
query: gql`${apollo.query}`,
data: data,
variables: apollo.variables
})
}
}
2021-11-28 17:29:17 +00:00
const { me, price } = props
2021-04-12 18:05:09 +00:00
return (
2021-11-13 13:28:08 +00:00
<>
<NextNProgress
color='var(--primary)'
startPosition={0.3}
stopDelayMs={200}
height={2}
showOnShallow
options={{ showSpinner: false }}
/>
<PlausibleProvider domain='stacker.news' trackOutboundLinks>
<Provider session={session}>
<ApolloProvider client={client}>
2021-11-28 17:29:17 +00:00
<MeProvider me={me}>
<PriceProvider price={price}>
<LightningProvider>
<FundErrorProvider>
<FundErrorModal />
<ItemActProvider>
<ItemActModal />
<Component {...props} />
</ItemActProvider>
</FundErrorProvider>
</LightningProvider>
</PriceProvider>
2021-11-13 13:28:08 +00:00
</MeProvider>
</ApolloProvider>
</Provider>
</PlausibleProvider>
</>
2021-04-12 18:05:09 +00:00
)
2021-03-22 20:36:10 +00:00
}
export default MyApp