mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix: hydration errors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
import { Moon, Sun, Check, SunMoon } from "lucide-react"
|
||||
import { useTheme } from "next-themes"
|
||||
import { useEffect, useState } from "react"
|
||||
import { authClient } from "@/lib/auth/auth-client"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
@@ -20,6 +21,8 @@ const themes = [
|
||||
|
||||
export function ModeToggle() {
|
||||
const { theme } = useTheme()
|
||||
const [mounted, setMounted] = useState(false)
|
||||
useEffect(() => setMounted(true), [])
|
||||
|
||||
const handleThemeChange = async (newTheme: "light" | "system" | "dark") => {
|
||||
await authClient.updateUser({ theme: newTheme })
|
||||
@@ -29,7 +32,7 @@ export function ModeToggle() {
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<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>
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
+1
-53
@@ -290,7 +290,6 @@ export const auth = betterAuth({
|
||||
]
|
||||
: []),
|
||||
openAPI(),
|
||||
nextCookies(),
|
||||
twoFactor(),
|
||||
organization({
|
||||
ac,
|
||||
@@ -311,6 +310,7 @@ export const auth = betterAuth({
|
||||
superadmin,
|
||||
},
|
||||
}),
|
||||
nextCookies(),
|
||||
],
|
||||
advanced: {
|
||||
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) => {
|
||||
const trustedOrigins = await queryTrustedDomains();
|
||||
return trustedOrigins;
|
||||
@@ -578,29 +549,6 @@ const queryTrustedDomains = async (): Promise<string[]> => {
|
||||
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 (
|
||||
name: string,
|
||||
email: string,
|
||||
|
||||
Reference in New Issue
Block a user