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 layout auth boolean logic bug #3547

Merged
merged 6 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 6 additions & 2 deletions apps/toolkit-app/app/core/layouts/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from "react"
import Head from "next/head"
import React, { FC } from "react"
import { BlitzLayout } from "@blitzjs/next"

const Layout: FC<{ title?: string; children?: React.ReactNode }> = ({ title, children }) => {
const Layout: BlitzLayout<{ title?: string; children?: React.ReactNode }> = ({
title,
children,
}) => {
return (
<>
<Head>
Expand Down
4 changes: 2 additions & 2 deletions packages/blitz-auth/src/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ export function getAuthValues<TProps = any>(
) {
if (!Page) return {}

let authenticate = "authenticate" in Page && Page.authenticate
let redirectAuthenticatedTo = "redirectAuthenticatedTo" in Page && Page.redirectAuthenticatedTo
let authenticate = (Page as BlitzPage)?.authenticate
let redirectAuthenticatedTo = (Page as BlitzPage)?.redirectAuthenticatedTo

if (authenticate === undefined && redirectAuthenticatedTo === undefined) {
const layout = "getLayout" in Page && Page.getLayout?.(<Page {...props} />)
Expand Down
4 changes: 2 additions & 2 deletions packages/blitz-next/src/index-browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
Simplify,
} from "blitz"
import Head from "next/head"
import React from "react"
import React, {ReactNode} from "react"
import {QueryClient, QueryClientProvider} from "react-query"
import {Hydrate, HydrateOptions} from "react-query/hydration"
import {withSuperJSONPage} from "./superjson"
Expand Down Expand Up @@ -80,7 +80,7 @@ export type BlitzPage<P = {}> = React.ComponentType<P> & {
suppressFirstRenderFlicker?: boolean
redirectAuthenticatedTo?: RedirectAuthenticatedTo | RedirectAuthenticatedToFn
}
export type BlitzLayout<P = {}> = React.ComponentType<P> & {
export type BlitzLayout<P = {}> = React.ComponentType<P & {children: ReactNode}> & {
authenticate?: boolean | {redirectTo?: string | RouteUrlObject}
redirectAuthenticatedTo?: RedirectAuthenticatedTo | RedirectAuthenticatedToFn
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Head from "next/head"
import React, { FC } from "react"
import React, {FC} from "react"
import {BlitzLayout} from "@blitzjs/next"

const Layout: FC<{ title?: string; children?: React.ReactNode }> = ({ title, children }) => {
const Layout: BlitzLayout<{title?: string; children?: React.ReactNode}> = ({title, children}) => {
return (
<>
<Head>
Expand Down