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

interface SubComponents {
  Loading: typeof CustomerSearchLoading;
}

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

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

CustomerSearchWrapper.Loading = CustomerSearchLoading;

export default CustomerSearchWrapper;