import { env } from "@code/env/native";
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.EXPO_PUBLIC_CONVEX_URL, {
  unsavedChangesWarning: false,
});

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