import React from 'react'
import { getPageSession } from '@/auth/lucia'
import Modal from '@/components/Modal'
import { redirect } from 'next/navigation'

interface Props {
  children: React.ReactNode
}

const Layout = async ({ children }: Props) => {
  const session = await getPageSession()

  // You can handle redirection or other logic based on the session here
  if (session) redirect('/dashboard');

  // Passing session to each child

  return <Modal className="max-w-sm">{children}</Modal>
}

export default Layout
