"use client";

import Loading from "@/app/loading";
import Breadcrumb from "@/components/Breadcrumbs/Breadcrumb";
import CreateAdminForm from "@/components/forms/admins/CreateAdmin";
import { useAdminDetails } from "@/hooks/queries";
import React, { 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;
