"use client";
import Loading from "@/app/loading";
import Breadcrumb from "@/components/Breadcrumbs/Breadcrumb";

import CreateCompany from "@/components/forms/companies/CreateCompany";
import { useCompanyDetails } from "@/hooks/queries";
import { use } from "react";

const EditCompanyPage = ({ params }: { params: Promise<{ id: string }> }) => {
  const { id } = use(params);
  const { isLoading, data } = useCompanyDetails(id);
  const breadcrumbItems = [
    { name: "Dashboard", href: "/" },
    { name: "Company", href: "/companies" },
    { name: "Edit company", href: `/companies/edit/${id}` },
  ];
  if (isLoading) return <Loading />;
  return (
    <>
      <Breadcrumb items={breadcrumbItems} />
      <CreateCompany editMode defaultValues={data.data} id={id} />
    </>
  );
};

export default EditCompanyPage;
