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

fix: Move AuthProvider to the RootApp to share between all page components #505

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions src/pages/[eventAbbr]/ui/admin/check_in_event/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import React, { useMemo } from 'react'
import { Layout } from '../../../../../components/Layout'
import { useGetApiV1EventsByEventAbbrQuery } from '../../../../../generated/dreamkast-api.generated'
import { useRouter } from 'next/router'
import { withAuthProvider } from '../../../../../context/auth'
import Error404 from '../../../../404'
import { CheckIn } from '../../../../../components/CheckIn/CheckIn'
import { Typography } from '@material-ui/core'
import { useSelector } from 'react-redux'
import { authSelector } from '../../../../../store/auth'

const IndexPage: NextPage = () => {
return withAuthProvider(<IndexMain />)
return <IndexMain />
}

const IndexMain = () => {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/[eventAbbr]/ui/admin/check_in_session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import {
useGetApiV1TalksQuery,
} from '../../../../../generated/dreamkast-api.generated'
import { useRouter } from 'next/router'
import { withAuthProvider } from '../../../../../context/auth'
import Error404 from '../../../../404'
import { CheckIn } from '../../../../../components/CheckIn/CheckIn'
import { MenuItem, Select, Typography } from '@material-ui/core'
import { authSelector } from '../../../../../store/auth'
import { useSelector } from 'react-redux'

const IndexPage: NextPage = () => {
return withAuthProvider(<IndexMain />)
return <IndexMain />
}

const IndexMain = () => {
Expand Down
5 changes: 2 additions & 3 deletions src/pages/[eventAbbr]/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NextPage } from 'next'
import { useInitSetup } from '../../../components/hooks/useInitSetup'
import { useGetTalksAndTracks } from '../../../components/hooks/useGetTalksAndTracks'
import { useRouterQuery } from '../../../components/hooks/useRouterQuery'
import { withAuthProvider } from '../../../context/auth'
import { NextTalkNotifier } from '../../../components/Layout/NextTalkNotifier'
import { ENV } from '../../../config'
import { useRouter } from 'next/router'
Expand All @@ -16,7 +15,7 @@ import { TrackLTView } from '../../../components/TrackLT'
import { showLTSelector } from '../../../store/settings'

const IndexPage: NextPage = () => {
return withAuthProvider(<IndexMain />)
return <IndexMain />
}

const IndexMain = () => {
Expand Down Expand Up @@ -90,7 +89,7 @@ const IndexMain = () => {
)
}

// TODO move to RootApp component
// TODO remove this ( seems not needed )
export const getServerSideProps = async () => {
return {
props: {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/[eventAbbr]/ui/info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import { Layout } from '../../../../components/Layout'
import { RegisteredTalks } from '../../../../components/RegisteredTalks'
import { Typography } from '@material-ui/core'
import { ENV } from '../../../../config'
import { withAuthProvider } from '../../../../context/auth'

const IndexPage: NextPage = () => {
return withAuthProvider(<IndexMain />)
return <IndexMain />
}

const IndexMain: NextPage = () => {
Expand Down
5 changes: 4 additions & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { setApiBaseUrl, setDkUrl, setWsBaseUrl } from '../store/auth'
import { ENV, validateEnv } from '../config'
import { PrivateCtxProvider } from '../context/private'
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client'
import { AuthProvider } from 'src/context/auth'

const GlobalStyle = createGlobalStyle`
html, body {
Expand Down Expand Up @@ -84,7 +85,9 @@ const RootApp = ({ Component, pageProps, env }: RootAppProps) => {
<PrivateCtxProvider env={env}>
<AppComponent>
<ApolloProvider client={client}>
<Component {...pageProps} />
<AuthProvider>
<Component {...pageProps} />
</AuthProvider>
</ApolloProvider>
</AppComponent>
</PrivateCtxProvider>
Expand Down
Loading