import { useEffect, type PropsWithChildren } from "react";

export function ZootechThemeProvider({ children }: PropsWithChildren): JSX.Element {
  useEffect(() => {
    const root = document.documentElement;
    const previousTheme = root.getAttribute("data-theme");
    root.setAttribute("data-theme", "organic");

    return () => {
      if (previousTheme) {
        root.setAttribute("data-theme", previousTheme);
        return;
      }
      root.removeAttribute("data-theme");
    };
  }, []);

  return <>{children}</>;
}
