import { redirect } from "next/navigation" import { asc, eq } from "drizzle-orm" import { db } from "@/lib/db" import { properties } from "@/lib/db/schema" import { getSessionUser } from "@/lib/session" import { TenantForm } from "@/components/forms/tenant-form" import { BackButton } from "@/components/ui/back-button" export const metadata = { title: "Add Tenant" } export default async function NewTenantPage() { const user = await getSessionUser() if (!user) redirect("/login") const properties_ = await db.query.properties.findMany({ where: eq(properties.user_id, user.id), columns: { id: true, name: true }, with: { units: { columns: { id: true, unit_number: true, status: true } }, }, orderBy: asc(properties.name), }) return (
Add a tenant and assign them to a unit