fix(frontend): fix routine step numbering and product name display

Steps were numbered from 2 due to off-by-one (order_index + 1).
Product steps showed "Unknown step" because the template checked
step.product (never returned by API) instead of looking up by
step.product_id in the already-loaded products list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Piotr Oleszczyk 2026-03-01 01:04:28 +01:00
parent f72d5ba1b7
commit 9524e4df54

View file

@ -93,11 +93,12 @@
{#each routine.steps.toSorted((a, b) => a.order_index - b.order_index) as step (step.id)} {#each routine.steps.toSorted((a, b) => a.order_index - b.order_index) as step (step.id)}
<div class="flex items-center justify-between rounded-md border border-border px-4 py-3"> <div class="flex items-center justify-between rounded-md border border-border px-4 py-3">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<span class="text-xs text-muted-foreground w-4">{step.order_index + 1}</span> <span class="text-xs text-muted-foreground w-4">{step.order_index}</span>
<div> <div>
{#if step.product} {#if step.product_id}
<p class="text-sm font-medium">{step.product.name}</p> {@const product = products.find((p) => p.id === step.product_id)}
<p class="text-xs text-muted-foreground">{step.product.brand}</p> <p class="text-sm font-medium">{product?.name ?? step.product_id}</p>
{#if product?.brand}<p class="text-xs text-muted-foreground">{product.brand}</p>{/if}
{:else if step.action_type} {:else if step.action_type}
<p class="text-sm font-medium">{step.action_type.replace(/_/g, ' ')}</p> <p class="text-sm font-medium">{step.action_type.replace(/_/g, ' ')}</p>
{:else} {:else}