"use client";

import Breadcrumb from "@/components/Breadcrumbs/Breadcrumb";
import CreateAdminForm from "@/components/forms/admins/CreateAdmin";
import Loading from "@/components/loading";
import { useAdminDetails } from "@/hooks/queries";
import { use } from "react";

const AdminEditPage = ({ params }: { params: Promise<{ id: string }> }) => {
  const { id } = use(params);
  const { data: adminDetails, isLoading } = useAdminDetails(id);
  const breadcrumbItems = [
    { name: "Dashboard", href: "/" },
    { name: "Admins", href: "/admins" },
    { name: "Edit Admin", href: `/admins/edit/${id}` },
  ];
  if (isLoading) return <Loading />;
  return (
    <>
      <Breadcrumb items={breadcrumbItems} />
      <CreateAdminForm editMode defaultValues={adminDetails?.data} id={id} />
    </>
  );
};

export default AdminEditPage;
