// src/commands/woCreate.js
// DM-only: post Adaptive Card to create a ServiceChannel work order.

import { logger } from '../utils/logger.js';
import {
  postCreateWorkOrderCard,
} from '../services/workOrderCreateService.js';
import { isWorkOrderCreateEnabled } from '../config/workOrderCreateConfig.js';

export async function handleWoCreate(bot, trigger) {
  logger('wo:create', 'HANDLER ENTERED');

  if (trigger.message?.roomType === 'group') {
    await bot.say(
      '**`/createWO`** is only available in a **1:1** chat with ServChan.\n\n' +
        'Open a direct message with the bot and run `/createWO` there.'
    );
    return;
  }

  if (!isWorkOrderCreateEnabled()) {
    await bot.say('Work order creation is disabled on this bot.');
    return;
  }

  await postCreateWorkOrderCard(bot, trigger);
}
