"use client";

import Sidebar, { useAdminAuth } from "@/components/admin/Sidebar";

export default function DashboardLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const { user, loading, handleLogout } = useAdminAuth();

  return (
    <div className="admin-layout">
      <Sidebar user={user} loading={loading} onLogout={handleLogout} />
      <main className="admin-main">
        {!user && !loading && (
          <div style={{ display: "flex", alignItems: "center", justifyContent: "center", height: "100%" }}>
            <div className="loading"><span>加载中...</span></div>
          </div>
        )}
        {(!loading || user) && children}
      </main>
    </div>
  );
}
