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: Resolve multiple ClerkProvider issue and hide Reset HUD button when user is not authenticated #100

Closed
wants to merge 8 commits into from
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Metadata } from "next"
import { jetbrainsMono } from '@/lib/fonts'
import "./globals.css"
import { siteConfig } from "./siteConfig"
import ResetHUDButton from "@/components/ResetHUDButton"
import ClientResetHUDButton from "@/components/ClientResetHUDButton"

export const metadata: Metadata = {
metadataBase: new URL("https://openagents.com"),
Expand Down Expand Up @@ -40,7 +40,7 @@ export default function RootLayout({
className={`${jetbrainsMono.variable} min-h-screen scroll-auto antialiased selection:bg-white selection:text-black dark:bg-black font-mono`}
>
<div className="fixed top-4 right-4 z-50">
<ResetHUDButton />
<ClientResetHUDButton />
</div>
{children}
</body>
Expand Down
25 changes: 25 additions & 0 deletions components/ClientResetHUDButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use client";

import React from 'react';
import { useAuth, ClerkProvider } from "@clerk/nextjs";
import ResetHUDButton from "./ResetHUDButton";

const AuthenticatedResetHUDButton: React.FC = () => {
const { isSignedIn } = useAuth();

if (!isSignedIn) {
return null;
}

return <ResetHUDButton />;
};

const ClientResetHUDButton: React.FC = () => {
return (
<ClerkProvider>
<AuthenticatedResetHUDButton />
</ClerkProvider>
);
};

export default ClientResetHUDButton;
Loading