import React from "react";
import EditUser from "./EditUser";
import EditUserLoading from "./EditUserLoading";
// import { fetchTeam, fetchTeamLeads } from "@/app/api/Team";
import { useSearchParams } from "next/navigation";
import { fetchPwRules } from "@/app/api/user";
import { searchParamsProps } from "@/app/utils/fetchUtil";
import { fetchUserDetails } from "@/app/api/user/actions";

interface SubComponents {
  Loading: typeof EditUserLoading;
}

const EditUserWrapper: React.FC<searchParamsProps> & SubComponents = async ({
  searchParams,
}) => {
  const id = parseInt(searchParams.id as string);
  const [pwRule, user] = await Promise.all([fetchPwRules(), fetchUserDetails(id)]);

  return <EditUser user={{ ...user.data, authIds: user.authIds }} rules={pwRule} />;
};

EditUserWrapper.Loading = EditUserLoading;

export default EditUserWrapper;
