import { addQuoteRpaJob } from "@/workers/rpa/queue";
import type { NormalizedCargo } from "@/modules/quote/types";

export type QuoteJobData = {
  quoteId: string;
  requestId: string;
  customerId: string;
  cargoHash: string;
  cargo: NormalizedCargo;
};

/** BullMQ 入队（task-021） */
export async function enqueueQuoteJob(data: QuoteJobData): Promise<void> {
  if (process.env.RPA_QUEUE_ENABLED === "false") {
    console.log(
      `[rpa-queue] 队列已禁用 quote_id=${data.quoteId} cargo_hash=${data.cargoHash}`,
    );
    return;
  }

  await addQuoteRpaJob(data);
  console.log(
    `[rpa-queue] 已入队 quote_id=${data.quoteId} cargo_hash=${data.cargoHash}`,
  );
}
