// packages/marketing-pages/src/integrations/cms/jobs/send-welcome-email.task.ts
import type { TaskConfig } from "payload";
import { marketingPagesContainer } from "../../../di/container";
import { MARKETING_PAGES_SYMBOLS } from "../../../di/symbols";
import type { ISendWelcomeEmailJob } from "../../../jobs/send-welcome-email.job";
import type { SendWelcomeEmailInput } from "../../../jobs/send-welcome-email.job";

export const sendWelcomeEmailTask: TaskConfig<{
  input: SendWelcomeEmailInput;
  output: object;
}> = {
  slug: "marketing-pages.send-welcome-email",
  inputSchema: [],
  retries: { attempts: 3, backoff: { type: "exponential", delay: 1000 } },
  handler: async ({ input }) => {
    const job = marketingPagesContainer.get<ISendWelcomeEmailJob>(
      MARKETING_PAGES_SYMBOLS.ISendWelcomeEmailJob,
    );
    await job(input);
    return { output: {} };
  },
};
