"use client";

import { useEffect } from "react";
import { useAppDispatch } from "../hooks/useAppRedux";
import { updateUser } from "../store/slices/user";
import { ProfileResponse } from "../hooks/features/profile/useProfileFetch";

export default function StoreHydrator({
  profile,
}: {
  profile: ProfileResponse & { balance: number };
}) {
  const dispatch = useAppDispatch();

  useEffect(() => {
    dispatch(
      updateUser({
        ...profile,
        isVerified: profile.emailVerified,
        balance: profile.balance || 0,
      }),
    );
  }, []);

  return null;
}
