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

export interface GetWorkflowsQuery { type: 'get-workflows'; }

export interface WorkflowItem {
  id: number;
  name: string;
  target: string;
  qty: number;
  createdAt: number;
  materials: Array<{ name: string; needed: number; done: number }>;
  steps: Array<{
    gen: number;
    crossings: Array<{ race: string; needed: number; parentA: string; parentB: string; couples: number; repro: number; done: number }>;
  }>;
}

export function createGetWorkflowsHandler(state: AppState) {
  return (_query: GetWorkflowsQuery): WorkflowItem[] => state.workflows as WorkflowItem[];
}
