import type { AppState, StateRepository } from '@domain/ports/StateRepository';

export interface DeleteWorkflowCommand {
  type: 'delete-workflow';
  workflowId: number;
}

export function createDeleteWorkflowHandler(state: AppState, repo: StateRepository) {
  return (cmd: DeleteWorkflowCommand): void => {
    state.workflows = (state.workflows as { id: number }[]).filter(w => w.id !== cmd.workflowId);
    repo.save(state);
  };
}
