"use client";

import { useEffect } from "react";
import useUserStore from "@/store/userStore";

export default function AuthProvider({ children }) {
  const fetchUser = useUserStore((state) => state.fetchUser);
  const fetched = useUserStore((state) => state.fetched);

  useEffect(() => {
    if (!fetched) {
      fetchUser();
    }
  }, [fetchUser, fetched]);

  return children;
}
