const { Op } = require('sequelize');

const qcPatterns = [
  { role_name: { [Op.like]: '%quality%control%' } },
  { role_code: { [Op.like]: '%quality%control%' } },
  { role_code: { [Op.like]: '%quality_control%' } },
  { role_code: { [Op.like]: '%qc%' } },
  { role_name: { [Op.like]: '%qc%' } },
];

const qaInspectorPatterns = [
  { role_name: { [Op.like]: '%qa%inspect%' } },
  { role_code: { [Op.like]: '%qa%inspect%' } },
  { role_code: { [Op.like]: '%qa_inspector%' } },
  { role_name: { [Op.like]: '%quality%inspect%' } },
  { role_code: { [Op.like]: '%quality_inspect%' } },
];

/**
 * Role LIKE patterns for Route Card PDF pickers (master /user list).
 */
const ROUTE_CARD_PDF_ROLE_PATTERNS = {
  production_manager: [
    { role_code: { [Op.like]: '%prodmgr%' } },
    { role_code: { [Op.like]: '%prod_mgr%' } },
    { role_code: { [Op.like]: '%production_manager%' } },
    { role_code: { [Op.like]: '%productionmgr%' } },
    { role_name: { [Op.like]: '%production%manager%' } },
    { role_name: { [Op.like]: '%prod%manager%' } },
  ],
  accountant: [
    { role_code: { [Op.like]: '%account%' } },
    { role_name: { [Op.like]: '%account%' } },
    { role_name: { [Op.like]: '%Accountant%' } },
  ],
  qc: qcPatterns,
  qa_inspector: qaInspectorPatterns,
  qc_incharge: [...qcPatterns, ...qaInspectorPatterns],
};

module.exports = { ROUTE_CARD_PDF_ROLE_PATTERNS };
