import can, {CanAccessResponse} from '@/actions/permission'
import LoginForm from '@/components/auth/forms/login-form'
import CabinetIndex from '@/components/cabinet'
import {Access} from '@/lib/permission'

export default async function CabinetPage({
	params
}: {
	params: Promise<{slug?: string[]}>
}) {
	const user = (await can(Access.Cabinet)) as CanAccessResponse

	if (!user.can || !user.session) {
		return (
			<div className='my-8'>
				<div className='container flex flex-col sm:flex-row'>
					<LoginForm />
				</div>
			</div>
		)
	} else {
		const {slug} = await params

		return <CabinetIndex slug={slug} session={user.session} />
	}
}
