"use client"; import { useTranslations } from "next-intl"; type Step = { id: string; instruction: string; appliesTo: string[]; }; function sectionLabel(appliesTo: string[], prepLabel: string): string { return appliesTo.length === 0 ? prepLabel : appliesTo.join(" + "); } export function BatchCookSteps({ steps }: { steps: Step[] }) { const t = useTranslations("recipe"); const prepLabel = t("batchCookPrep"); const groups: Array<{ label: string; steps: Step[] }> = []; for (const step of steps) { const label = sectionLabel(step.appliesTo, prepLabel); const last = groups[groups.length - 1]; if (last && last.label === label) last.steps.push(step); else groups.push({ label, steps: [step] }); } let stepNumber = 0; return (
{groups.map((group, gi) => (

{group.label}

    {group.steps.map((step) => { stepNumber += 1; return (
  1. {stepNumber}

    {step.instruction}

  2. ); })}
))}
); }