import { WorkflowTrigger } from '@/workflow/types/Workflow';
import { getTriggerDefaultLabel } from '@/workflow/workflow-trigger/utils/getTriggerLabel';
import { assertUnreachable } from 'twenty-shared/utils';

export const getTriggerHeaderType = (trigger: WorkflowTrigger) => {
  switch (trigger.type) {
    case 'CRON': {
      return 'Trigger';
    }
    case 'WEBHOOK': {
      return 'Trigger · Webhook';
    }
    case 'MANUAL': {
      return 'Trigger · Manual';
    }
    case 'DATABASE_EVENT': {
      const defaultLabel = getTriggerDefaultLabel(trigger);

      return `Trigger · ${defaultLabel}`;
    }
    default: {
      assertUnreachable(trigger, 'Unknown trigger type');
    }
  }
};
