"use client";
import { useEffect } from "react";

export default function UserInitializer() {
  useEffect(() => {
    (async () => {
      try {
        const res = await fetch("/api/me", { credentials: "include", cache: "no-store" });
        if (!res.ok) return;
        const me = await res.json();
        if (me?.first_name) localStorage.setItem("first_name", me.first_name);
      } catch (e) {
        // noop
      }
    })();
  }, []);
  return null;
}