import { notFound } from "next/navigation"

import { CategoryService } from "@/services/category.service"

import EditCategoryForm from "../../_components/edit.category.form"

export default async function EditCategoryPage({
  params,
}: {
  params: Promise<{ categoryId: string }>
}) {
  const { categoryId } = await params
  const category = await CategoryService.findById(categoryId)

  if (!category) {
    notFound()
  }

  return (
    <div className="flex flex-col gap-4">
      <div className="flex items-center justify-between gap-4">
        <h1 className="text-2xl font-bold">Edit Category</h1>
      </div>
      <EditCategoryForm category={category} />
    </div>
  )
}
