
import Footer from '@/share/Footer'
import Header from '@/share/Header'
import { FC, ComponentType } from 'react'
// import Header from '@/share/Header'

interface LayoutProps {
    children: React.ReactNode
}

const Layout: FC<LayoutProps> = ({ children }) => {
    return (
        <div className="min-h-screen flex flex-col">
            <Header />
            <main className="flex-1">
                {children}
            </main>
            <Footer />
        </div>
    )
}

// HOC function
function withLayout<P extends object>(WrappedComponent: ComponentType<P>) {
    const WithLayoutComponent: FC<P> = (props) => {
        return (
            <Layout>
                <WrappedComponent {...props} />
            </Layout>
        )
    }

    WithLayoutComponent.displayName = `withLayout(${WrappedComponent.displayName || WrappedComponent.name})`

    return WithLayoutComponent
}

export default withLayout
export { Layout }
