import Skeleton from "@mui/material/Skeleton";

export function PageSkeleton() {
  return (
    <div className="page-skeleton" aria-hidden="true">
      <div className="page-skeleton__head">
        <SkeletonBlock className="page-skeleton__title" />
        <div className="page-skeleton__actions">
          <SkeletonBlock />
          <SkeletonBlock />
        </div>
      </div>

      <div className="page-skeleton__kpis">
        {Array.from({ length: 5 }, (_, index) => (
          <SkeletonBlock className="page-skeleton__kpi" key={index} />
        ))}
      </div>

      <div className="page-skeleton__charts">
        {Array.from({ length: 4 }, (_, index) => (
          <SkeletonBlock className="page-skeleton__chart" key={index} />
        ))}
      </div>

      <div className="page-skeleton__content">
        <SkeletonBlock className="page-skeleton__rail" />
        <SkeletonBlock className="page-skeleton__table" />
      </div>
    </div>
  );
}

function SkeletonBlock({ className = "" }) {
  return <Skeleton animation="wave" className={["page-skeleton__block", className].filter(Boolean).join(" ")} variant="rounded" />;
}
