"use client";

import { useEffect } from "react";

export function ThemeLoader() {
  useEffect(() => {
    fetch("/api/theme")
      .then((r) => r.json())
      .then((theme: Record<string, string>) => {
        const root = document.documentElement;
        for (const [key, value] of Object.entries(theme)) {
          if (value) root.style.setProperty("--" + key, value);
        }
      })
      .catch(() => {});
  }, []);
  return null;
}
