// import { fetchUserAbilities } from "@/app/utils/fetchUtil";
import MailSetting from "./MailSetting";
import MailSettingLoading from "./MailSettingLoading";
import { fetchMailSetting, fetchMailTemplates } from "@/app/api/mail";

interface SubComponents {
  Loading: typeof MailSettingLoading;
}

const MailSettingWrapper: React.FC & SubComponents = async () => {
  const [
    // abilities,
    settings,
    templates,
    // timesheetTemplate,
  ] = await Promise.all([
    // fetchUserAbilities(),
    fetchMailSetting(),
    fetchMailTemplates(),
    // fetchMailTimesheetTemplate()
  ]);

  // const tempTimesheetTemplate: MailTemplate = {
  //     cc: timesheetTemplate.find(template => template.name.includes(".cc"))?.value,
  //     bcc: timesheetTemplate.find(template => template.name.includes(".bcc"))?.value,
  //     subject: timesheetTemplate.find(template => template.name.includes(".subject"))?.value,
  //     template: timesheetTemplate.find(template => template.name.includes(".template"))?.value,
  // }
  return (
    <MailSetting
      defaultInputs={{
        settings: settings,
        templates: templates,
        // template: tempTimesheetTemplate,
      }}
    />
  );
};

MailSettingWrapper.Loading = MailSettingLoading;

export default MailSettingWrapper;
