"use client";
import { useSessionPlayerStore } from "@/lib/store/current-player-store";
import type { Player } from "@/server/db/schema";
import React from "react";

function AppProvider({
  initialSessionPlayer,
  children,
}: {
  initialSessionPlayer?: Player | null;
  children: React.ReactNode;
}) {
  const setSessionPlayer = useSessionPlayerStore(
    (state) => state.setSessionPlayer,
  );
  React.useEffect(() => {
    setSessionPlayer(initialSessionPlayer);
  }, [initialSessionPlayer]);
  return children;
}

export default AppProvider;
