"use client";
import Loading from "@/app/loading";
import Breadcrumb from "@/components/Breadcrumbs/Breadcrumb";
import CreateCompanyCategoryForm from "@/components/forms/companies/company-categories/CreateCompanyCategory";
import { useCompanyCategoriesDetails } from "@/hooks/queries";
import { BreadcrumbItem } from "@/types/shared";
import { use } from "react";

const EditCompanyCategory = ({
  params,
}: {
  params: Promise<{ id: string }>;
}) => {
  const { id } = use(params);
  const { isLoading, data } = useCompanyCategoriesDetails(id);
  const breadcrumbItems: BreadcrumbItem[] = [
    { name: "Dashboard", href: "/" },
    { name: "Company Categories", href: "/companies/categories" },
    { name: "Edit Company Category", href: `/companies/categories/edit/${id}` },
  ];
  if (isLoading) return <Loading />;
  return (
    <>
      <Breadcrumb items={breadcrumbItems} />
      <CreateCompanyCategoryForm defaultValues={data?.data} editMode id={id} />
    </>
  );
};

export default EditCompanyCategory;
