import React from "react";
import { ConfigProvider } from "antd";
import { AntdRegistry } from "@ant-design/nextjs-registry";
import { ConfigProviderProps } from "antd/es/config-provider";

export default async function AntdProvider({
  children,
  lng,
}: {
  children: React.ReactNode;
  lng: string;
}) {
  const antConfig: ConfigProviderProps = {
    theme: {
      cssVar: {
        prefix: "ant",
        key: "css",
      },
      hashed: true,
      token: { fontFamily: "Alex" },
    },
  };
  return (
     <AntdRegistry>
      <ConfigProvider
        direction={lng === "ar" ? "rtl" : "ltr"}
        prefixCls="ant"
        {...antConfig}
      >
        {children}
      </ConfigProvider>
    </AntdRegistry>
  );
}
