Skip to content

Commit

Permalink
Merge branch 'develop' into scope-selector
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bar committed Nov 8, 2024
2 parents 8e3be44 + ad5e77e commit 18a596f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
10 changes: 10 additions & 0 deletions src/app/dev/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Entrypoint from '@/components/Entrypoint';
import { basePath } from '@/config';

export default function DevPage({
searchParams,
}: {
searchParams: { errorcode: string | undefined };
}) {
return <Entrypoint errorCode={searchParams.errorcode} callbackUrl={`${basePath}/virtual-lab`} />;
}
10 changes: 8 additions & 2 deletions src/components/Entrypoint/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ import ScreenBBGithub from '../home/screens/ScreenBBGithub';
import ScreenContributors from '../home/screens/ScreenContributors';
import { AcceptInviteErrorDialog, Menu } from './segments';

export default function Entrypoint({ errorCode }: { errorCode?: string }) {
export default function Entrypoint({
errorCode,
callbackUrl,
}: {
errorCode?: string;
callbackUrl?: string;
}) {
return (
<div className="relative flex w-screen flex-col bg-primary-9">
<Menu />
<Menu callbackUrl={callbackUrl} />
<div className="h-auto overflow-x-hidden overflow-y-scroll md:h-screen md:snap-y md:snap-mandatory">
<HeaderScreen />
<ScreenBBGithub />
Expand Down
13 changes: 11 additions & 2 deletions src/components/Entrypoint/segments/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ interface MenuButtonProps extends MenuItemProps {
action?: <T, RT>(input: T) => RT;
}

interface EntrypointMenuProps {
callbackUrl?: string;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function MenuButton({ bgcolor, title, action }: MenuButtonProps) {
const params = useSearchParams();
Expand Down Expand Up @@ -48,7 +52,7 @@ function MenuItem({ title, bgcolor = defaultBgColor }: MenuItemProps) {
);
}

export default function EntrypointMenu() {
export default function EntrypointMenu({ callbackUrl = '' }: EntrypointMenuProps) {
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState<boolean>(false);

return (
Expand Down Expand Up @@ -87,7 +91,12 @@ export default function EntrypointMenu() {
theme="dark"
/> */}
<PrimaryButtonHome label="About" url="/about" hasIcon={false} theme="dark" />
<PrimaryButtonHome label="Log in" url="/log-in" hasIcon={false} theme="light" />
<PrimaryButtonHome
label="Log in"
url={`/log-in?callbackUrl=${encodeURIComponent(callbackUrl)}`}
hasIcon={false}
theme="light"
/>
</div>
</div>
);
Expand Down
12 changes: 10 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getToken } from 'next-auth/jwt';
import nextAuthMiddleware, { NextRequestWithAuth } from 'next-auth/middleware';
import { NextRequest, NextResponse } from 'next/server';

const FREE_ACCESS_PAGES = ['/', '/log-in', '/getting-started', '/about*'];
const FREE_ACCESS_PAGES = ['/', '/log-in', '/getting-started', '/about*', '/dev'];
const ASSETS = [
'/static*',
'/images*',
Expand Down Expand Up @@ -50,8 +50,16 @@ export async function middleware(request: NextRequest) {
// }

// If the user is authenticated and wants to access the home page or log-in page
// then redirect to the main page
// then redirect to the explore home page
if (sessionValid && (requestUrl === '/' || requestUrl === '/log-in')) {
const url = request.nextUrl.clone();
url.pathname = `/explore/interactive`;
return NextResponse.redirect(url);
}

// If the user is authenticated and wants to access the /dev page
// then redirect to the virtual lab main page
if (sessionValid && requestUrl === '/dev') {
const url = request.nextUrl.clone();
url.pathname = `/virtual-lab`;
return NextResponse.redirect(url);
Expand Down

0 comments on commit 18a596f

Please sign in to comment.