import { env } from "@code/env/web";
import { ConvexBetterAuthProvider } from "@convex-dev/better-auth/react";
import { ConvexReactClient } from "convex/react";
import type { ReactNode } from "react";

import { authClient } from "./auth-client";

const convex = new ConvexReactClient(env.VITE_CONVEX_URL, { expectAuth: true });

export const WebAuthProvider = ({ children }: { children: ReactNode }) => (
  <ConvexBetterAuthProvider authClient={authClient} client={convex}>
    {children}
  </ConvexBetterAuthProvider>
);
