"use client";

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import { CustomerAdmin } from "@/components/customer-admin";
import { isMailMaliFlavor } from "@/lib/product-flavor";

export function CustomerAdminEntry() {
  const [client] = useState(
    () =>
      new QueryClient({
        defaultOptions: {
          queries: {
            refetchOnWindowFocus: false,
            retry: 1,
            staleTime: 20_000,
          },
        },
      })
  );

  useEffect(() => {
    const previousLang = document.documentElement.lang;
    document.documentElement.lang = "en";
    return () => {
      document.documentElement.lang = previousLang;
    };
  }, []);

  return (
    <QueryClientProvider client={client}>
      <CustomerAdmin variant={isMailMaliFlavor ? "mailmali" : "zimphony"} />
    </QueryClientProvider>
  );
}
