import { fetchAllCustomers } from "@/app/api/customer";
import React from "react";
import CustomerSearch from "./CustomerSearch";
import CustomerSearchLoading from "./CustomerSearchLoading";
import { fetchUserAbilities } from "@/app/utils/fetchUtil";

interface SubComponents {
  Loading: typeof CustomerSearchLoading;
}

const CustomerSearchWrapper: React.FC & SubComponents = async () => {
  const [customers, abilities] = await Promise.all([fetchAllCustomers(), fetchUserAbilities()]);

  return <CustomerSearch customers={customers} abilities={abilities}/>;
};

CustomerSearchWrapper.Loading = CustomerSearchLoading;

export default CustomerSearchWrapper;