diff --git a/src/app/(auth)/forgot-password/components/forgot-password-form-1.tsx b/src/app/(auth)/forgot-password/components/forgot-password-form-1.tsx index c1cdfce..7f3ff9e 100644 --- a/src/app/(auth)/forgot-password/components/forgot-password-form-1.tsx +++ b/src/app/(auth)/forgot-password/components/forgot-password-form-1.tsx @@ -9,7 +9,8 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { cn } from "@/lib/utils"; -import { forgotPasswordAction, initialAuthState } from "@/lib/appwrite/auth-actions"; +import { forgotPasswordAction } from "@/lib/appwrite/auth-actions"; +import { initialAuthState } from "@/lib/appwrite/auth-types"; export function ForgotPasswordForm1({ className, ...props }: React.ComponentProps<"div">) { const [state, formAction, isPending] = useActionState(forgotPasswordAction, initialAuthState); diff --git a/src/app/(auth)/sign-in/components/login-form-1.tsx b/src/app/(auth)/sign-in/components/login-form-1.tsx index 0915908..7782f29 100644 --- a/src/app/(auth)/sign-in/components/login-form-1.tsx +++ b/src/app/(auth)/sign-in/components/login-form-1.tsx @@ -10,7 +10,8 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Logo } from "@/components/logo"; import { cn } from "@/lib/utils"; -import { initialAuthState, signInAction } from "@/lib/appwrite/auth-actions"; +import { signInAction } from "@/lib/appwrite/auth-actions"; +import { initialAuthState } from "@/lib/appwrite/auth-types"; export function LoginForm1({ className, ...props }: React.ComponentProps<"div">) { const [state, formAction, isPending] = useActionState(signInAction, initialAuthState); diff --git a/src/app/(auth)/sign-up/components/signup-form-1.tsx b/src/app/(auth)/sign-up/components/signup-form-1.tsx index a00ae4b..6162c06 100644 --- a/src/app/(auth)/sign-up/components/signup-form-1.tsx +++ b/src/app/(auth)/sign-up/components/signup-form-1.tsx @@ -10,7 +10,8 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Logo } from "@/components/logo"; import { cn } from "@/lib/utils"; -import { initialAuthState, signUpAction } from "@/lib/appwrite/auth-actions"; +import { signUpAction } from "@/lib/appwrite/auth-actions"; +import { initialAuthState } from "@/lib/appwrite/auth-types"; export function SignupForm1({ className, ...props }: React.ComponentProps<"div">) { const [state, formAction, isPending] = useActionState(signUpAction, initialAuthState); diff --git a/src/lib/appwrite/auth-actions.ts b/src/lib/appwrite/auth-actions.ts index ab57b90..c0d347b 100644 --- a/src/lib/appwrite/auth-actions.ts +++ b/src/lib/appwrite/auth-actions.ts @@ -5,13 +5,7 @@ import { redirect } from "next/navigation"; import { AppwriteException, ID } from "node-appwrite"; import { APPWRITE_SESSION_COOKIE, createAdminClient, createSessionClient } from "./server"; - -export type AuthState = { - ok: boolean; - error?: string; -}; - -const initial: AuthState = { ok: false }; +import type { AuthState } from "./auth-types"; function appwriteError(e: unknown): string { if (e instanceof AppwriteException) { @@ -114,5 +108,3 @@ export async function signOutAction() { (await cookies()).delete(APPWRITE_SESSION_COOKIE); redirect("/sign-in"); } - -export const initialAuthState = initial; diff --git a/src/lib/appwrite/auth-types.ts b/src/lib/appwrite/auth-types.ts new file mode 100644 index 0000000..e8b40a2 --- /dev/null +++ b/src/lib/appwrite/auth-types.ts @@ -0,0 +1,6 @@ +export type AuthState = { + ok: boolean; + error?: string; +}; + +export const initialAuthState: AuthState = { ok: false };