"use client"

import AppBar from "@/components/module/app-bar"
import { SidebarProvider } from "@/components/ui/sidebar"
import PricePlanSidebar from "@/lib/price-plan/view/sidebar"
import { usePathname } from "next/navigation"
import React from "react"
import { Toaster } from "sonner"

interface Props {
    children: React.ReactNode
}

const MainLayout = ({
    children
}: Props) => {
    const pathname = usePathname()
    const match = pathname.match(/\/price-plan\/(\d+)/)

    return (
        <SidebarProvider>
            {!match && <PricePlanSidebar />}
            <section className="w-full">
                <AppBar useLogo={false} />
                <main className="py-4">
                    {children}
                </main>
            </section>
            <Toaster
                richColors
                position="top-right"
                duration={1500}
            />
        </SidebarProvider>
    )
}

export default MainLayout