import { RootState } from "@/store";
import React, { ReactNode } from "react";
import { useSelector } from "react-redux";

type Props = {
  aId: string;
  children: ReactNode;
};

function AuthCom({ aId, children }: Props) {
  // 从仓库获取有权限的id集合，已经整理了数据，格式为 ['1','2',...]
  const arr = useSelector((state: RootState) => state.A4Role.A4RoleAll);

  return <>{arr.find((v) => v === aId) || aId === "-1" ? children : null}</>;
}

const MemoAuthCom = React.memo(AuthCom);

export default MemoAuthCom;
