"use client";

import { SidebarProvider } from "../../src/components/Layouts/sidebar/sidebar-context";
import { ThemeProvider } from "next-themes";
import { Provider } from 'react-redux';
import { store } from '../../src/lib/store';
import { AuthInitializer } from '../../src/components/AuthInitializer';
import { usePathname } from "next/navigation";

export function Providers({ children }: { children: React.ReactNode }) {
  const pathname = usePathname();
  const isAdmin = pathname.startsWith("/admin");

  return (
    <Provider store={store}>
      <ThemeProvider
        attribute="class"
        defaultTheme="light"
        enableSystem={false}
        forcedTheme={isAdmin ? undefined : "light"}
      >
        <SidebarProvider>
          <AuthInitializer />
            {children}        
        </SidebarProvider>
      </ThemeProvider>
    </Provider>
  );
}
