Skip to content

Commit

Permalink
Exclude /auth/provider from layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Miklaszewski committed Apr 27, 2023
1 parent 94b5fde commit b6bc4f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
15 changes: 13 additions & 2 deletions apps/next-app/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ReactElement, ReactNode, useState } from 'react';
import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs';
import { NextPage } from 'next';
import { Layout } from 'shared/components/Layout';
import { ROUTES } from 'constants/ROUTES';

const nunito = Nunito({ subsets: ['latin'], weight: ['300', '500', '700'] });

Expand All @@ -18,7 +19,11 @@ type CustomAppProps = AppProps & {
initialSession: Session;
};

export default function App({ Component, pageProps }: CustomAppProps) {
export default function App({
Component,
pageProps,
...appProps
}: CustomAppProps) {
const [supabaseClient] = useState(() => createBrowserSupabaseClient());

return (
Expand All @@ -28,7 +33,13 @@ export default function App({ Component, pageProps }: CustomAppProps) {
>
<AppProviders>
<main className={nunito.className}>
<Component {...pageProps} />)
{appProps.router.pathname === ROUTES.PROVIDER ? (
<Component {...pageProps} />
) : (
<Layout>
<Component {...pageProps} />
</Layout>
)}
</main>
</AppProviders>
</SessionContextProvider>
Expand Down
7 changes: 2 additions & 5 deletions apps/next-app/src/pages/auth/provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ const Provider = () => {
useEffect(() => {
const getSession = async () => {
const session = await supabase.auth.getSession();
console.log('SESSION', session);
if (session) {
router.replace(ROUTES.DASHBOARD);
}
router.replace(session ? ROUTES.DASHBOARD : ROUTES.LOGIN);
};
getSession();
}, [router, supabase.auth]);

return <div>Provider</div>;
return null;
};

export default Provider;

0 comments on commit b6bc4f6

Please sign in to comment.