"use client";

import "@/lib/toast-patch";

import { ConvexProvider, ConvexReactClient } from "convex/react"
import { ReactNode } from "react"

import { DEFAULT_CONVEX_URL } from "@/lib/constants"

const resolvedConvexUrl = process.env.NEXT_PUBLIC_CONVEX_URL ?? DEFAULT_CONVEX_URL
const client = new ConvexReactClient(resolvedConvexUrl)

export function ConvexClientProvider({ children }: { children: ReactNode }) {
  return <ConvexProvider client={client}>{children}</ConvexProvider>
}
