fix: hydration errors

This commit is contained in:
charles-gauthereau
2026-05-28 20:50:05 +02:00
parent c9552e448a
commit d49d8f52c4
2 changed files with 5 additions and 54 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
"use client" "use client"
import { Moon, Sun, Check, SunMoon } from "lucide-react" import { Moon, Sun, Check, SunMoon } from "lucide-react"
import { useTheme } from "next-themes" import { useTheme } from "next-themes"
import { useEffect, useState } from "react"
import { authClient } from "@/lib/auth/auth-client" import { authClient } from "@/lib/auth/auth-client"
import { Button } from "@/components/ui/button" import { Button } from "@/components/ui/button"
@@ -20,6 +21,8 @@ const themes = [
export function ModeToggle() { export function ModeToggle() {
const { theme } = useTheme() const { theme } = useTheme()
const [mounted, setMounted] = useState(false)
useEffect(() => setMounted(true), [])
const handleThemeChange = async (newTheme: "light" | "system" | "dark") => { const handleThemeChange = async (newTheme: "light" | "system" | "dark") => {
await authClient.updateUser({ theme: newTheme }) await authClient.updateUser({ theme: newTheme })
@@ -29,7 +32,7 @@ export function ModeToggle() {
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon" className="size-8 rounded-full border border-input bg-transparent shadow-xs transition-transform active:scale-95"> <Button variant="ghost" size="icon" className="size-8 rounded-full border border-input bg-transparent shadow-xs transition-transform active:scale-95">
{theme === "light" ? <Sun className="size-4" /> : theme === "dark" ? <Moon className="size-4" /> : <SunMoon className="size-4" />} {!mounted || theme === "system" ? <SunMoon className="size-4" /> : theme === "light" ? <Sun className="size-4" /> : <Moon className="size-4" />}
<span className="sr-only">Toggle theme</span> <span className="sr-only">Toggle theme</span>
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
+1 -53
View File
@@ -290,7 +290,6 @@ export const auth = betterAuth({
] ]
: []), : []),
openAPI(), openAPI(),
nextCookies(),
twoFactor(), twoFactor(),
organization({ organization({
ac, ac,
@@ -311,6 +310,7 @@ export const auth = betterAuth({
superadmin, superadmin,
}, },
}), }),
nextCookies(),
], ],
advanced: { advanced: {
database: { database: {
@@ -529,35 +529,6 @@ export const auth = betterAuth({
}, },
}, },
}, },
/* databaseHooks: {
session: {
create: {
before: async (session) => {
const organizationId = await getLastOrganizationOrFirst(session.userId);
if (!organizationId) {
return {
...session,
};
}
const [aa] = await db
.update(drizzleUser.session)
.set({ activeOrganizationId: organizationId })
.where(eq(drizzleUser.session.id, session.id))
.returning();
return {
...session,
activeOrganizationId: organizationId,
};
},
},
},
},*/
// trustedOrigins: [env.PROJECT_URL!, "http://app"],
trustedOrigins: async (request) => { trustedOrigins: async (request) => {
const trustedOrigins = await queryTrustedDomains(); const trustedOrigins = await queryTrustedDomains();
return trustedOrigins; return trustedOrigins;
@@ -578,29 +549,6 @@ const queryTrustedDomains = async (): Promise<string[]> => {
return domains; return domains;
}; };
/*export const signUpUser = async (email: string, password: string, name: string) => {
const user = await auth.api.signUpEmail({
body: {
email,
password,
name,
},
});
return user;
};
export const signInUser = async (email: string, password: string) => {
const user = await auth.api.signInEmail({
body: {
email,
password,
},
});
return user;
};*/
export const createUser = async ( export const createUser = async (
name: string, name: string,
email: string, email: string,