import { UrlsDataTable } from "@/app/(admin)/dashboard/_components/urls-data-table"
import { getSession } from "@/lib/auth/session"
import { getAllUrls } from "@/lib/db/urls"

export default async function DashboardListPage() {
    const { session, redirect } = await getSession()

    if (!session) {
        redirect("/sign-in")
    }

    const urls = await getAllUrls()

    return (
        <div className="p-6">
            <div className="mb-6">
                <h1 className="text-2xl font-bold text-foreground mb-2 block">URLs</h1>
                <h1 className="text-muted-foreground block">Manage all your shortened URLs.</h1>
            </div>
            <UrlsDataTable data={urls} />
        </div>
    )
}
