Check for session in addition for isPublic prop (#6443)
* Check for session in addition for isPublic prop * Cleaner, more readable version * Less code same result, no rerender Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: zomars <zomars@me.com>pull/6409/head^2
parent
070d314897
commit
d2c4e2894d
|
@ -26,18 +26,18 @@ import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
||||||
import { SVGComponent } from "@calcom/types/SVGComponent";
|
import { SVGComponent } from "@calcom/types/SVGComponent";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
Credits,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuPortal,
|
DropdownMenuPortal,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
showToast,
|
|
||||||
Logo,
|
|
||||||
ErrorBoundary,
|
ErrorBoundary,
|
||||||
Credits,
|
|
||||||
HeadSeo,
|
HeadSeo,
|
||||||
Icon,
|
Icon,
|
||||||
|
Logo,
|
||||||
|
showToast,
|
||||||
SkeletonText,
|
SkeletonText,
|
||||||
} from "@calcom/ui";
|
} from "@calcom/ui";
|
||||||
|
|
||||||
|
@ -172,22 +172,28 @@ const CustomBrandingContainer = () => {
|
||||||
return <CustomBranding lightVal={user?.brandColor} darkVal={user?.darkBrandColor} />;
|
return <CustomBranding lightVal={user?.brandColor} darkVal={user?.darkBrandColor} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const KBarWrapper = ({ children, withKBar = false }: { withKBar: boolean; children: React.ReactNode }) =>
|
||||||
|
withKBar ? (
|
||||||
|
<KBarRoot>
|
||||||
|
{children}
|
||||||
|
<KBarContent />
|
||||||
|
</KBarRoot>
|
||||||
|
) : (
|
||||||
|
<>{children}</>
|
||||||
|
);
|
||||||
|
|
||||||
export default function Shell(props: LayoutProps) {
|
export default function Shell(props: LayoutProps) {
|
||||||
|
const { status } = useSession();
|
||||||
|
// if a page is unauthed and isPublic is true, the redirect does not happen.
|
||||||
useRedirectToLoginIfUnauthenticated(props.isPublic);
|
useRedirectToLoginIfUnauthenticated(props.isPublic);
|
||||||
useRedirectToOnboardingIfNeeded();
|
useRedirectToOnboardingIfNeeded();
|
||||||
useTheme("light");
|
useTheme("light");
|
||||||
// don't load KBar when unauthed
|
|
||||||
return props.isPublic ? (
|
return (
|
||||||
<>
|
<KBarWrapper withKBar={status === "authenticated"}>
|
||||||
<CustomBrandingContainer />
|
<CustomBrandingContainer />
|
||||||
<Layout {...props} />
|
<Layout {...props} />
|
||||||
</>
|
</KBarWrapper>
|
||||||
) : (
|
|
||||||
<KBarRoot>
|
|
||||||
<CustomBrandingContainer />
|
|
||||||
<Layout {...props} />
|
|
||||||
<KBarContent />
|
|
||||||
</KBarRoot>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue