import { STEPS } from '../constants';

/**
 * Enabled steps in order from config.features.*.required flags.
 * Channel selection, incentives, delivery, and dynamic controls are toggled independently.
 */
export const getEnabledSteps = (config) => {
  const { features = {} } = config;
  const steps = [];

  if (features.messageTypeData?.required) {
    steps.push(STEPS.MESSAGE_TYPE);
  }
  if (features.communicationStrategyData?.required) {
    steps.push(STEPS.COMMUNICATION_STRATEGY);
  }
  if (features.contentTemplateData?.required) {
    steps.push(STEPS.CHANNEL_SELECTION);
  }
  if (features.incentivesData?.required) {
    steps.push(STEPS.INCENTIVES);
  }
  if (features.deliverySettingsData?.required) {
    steps.push(STEPS.DELIVERY_SETTINGS);
  }
  if (features.dynamicControlsData?.required) {
    steps.push(STEPS.DYNAMIC_CONTROLS);
  }
  return steps;
};
