import type React from "react"
import { getCurrentUser } from "@/lib/auth"
import { redirect } from "next/navigation"
import Header from "@/components/layout/header"
import PlumberSidebar from "@/components/plumber/sidebar"

export default async function PlumberLayout({
  children,
}: {
  children: React.ReactNode
}) {
  const user = await getCurrentUser()

  if (!user) {
    redirect("/login")
  }

  if (user.role !== "plumber") {
    redirect("/login")
  }

  return (
    <div className="min-h-screen bg-[var(--bg-color)]">
      <Header />
      <div className="flex">
        <PlumberSidebar />
        <main className="flex-1 p-6">{children}</main>
      </div>
    </div>
  )
}
