fix(frontend): fix step numbering and client-side API base URL
- Step numbers now use each-block index (i+1) instead of order_index+1, fixing display when order_index starts from 1 in existing data - api.ts: browser-side requests use /api (nginx proxy) instead of PUBLIC_API_BASE (localhost:8000), fixing PATCH/client calls on remote hosts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5cb44b2c65
commit
d4e3040674
2 changed files with 7 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { browser } from '$app/environment';
|
||||||
import { PUBLIC_API_BASE } from '$env/static/public';
|
import { PUBLIC_API_BASE } from '$env/static/public';
|
||||||
import type {
|
import type {
|
||||||
ActiveIngredient,
|
ActiveIngredient,
|
||||||
|
|
@ -21,7 +22,10 @@ import type {
|
||||||
// ─── Core fetch helpers ──────────────────────────────────────────────────────
|
// ─── Core fetch helpers ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
async function request<T>(path: string, init: RequestInit = {}): Promise<T> {
|
async function request<T>(path: string, init: RequestInit = {}): Promise<T> {
|
||||||
const url = `${PUBLIC_API_BASE}${path}`;
|
// Server-side uses PUBLIC_API_BASE (e.g. http://localhost:8000).
|
||||||
|
// Browser-side uses /api so nginx proxies the request on the correct host.
|
||||||
|
const base = browser ? '/api' : PUBLIC_API_BASE;
|
||||||
|
const url = `${base}${path}`;
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, {
|
||||||
headers: { 'Content-Type': 'application/json', ...init.headers },
|
headers: { 'Content-Type': 'application/json', ...init.headers },
|
||||||
...init
|
...init
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@
|
||||||
onfinalize={handleFinalize}
|
onfinalize={handleFinalize}
|
||||||
class="space-y-2"
|
class="space-y-2"
|
||||||
>
|
>
|
||||||
{#each steps as step (step.id)}
|
{#each steps as step, i (step.id)}
|
||||||
<div class="rounded-md border border-border bg-background">
|
<div class="rounded-md border border-border bg-background">
|
||||||
{#if editingStepId === step.id}
|
{#if editingStepId === step.id}
|
||||||
<!-- ── Edit mode ── -->
|
<!-- ── Edit mode ── -->
|
||||||
|
|
@ -277,7 +277,7 @@
|
||||||
class="cursor-grab select-none px-1 text-muted-foreground/60 hover:text-muted-foreground"
|
class="cursor-grab select-none px-1 text-muted-foreground/60 hover:text-muted-foreground"
|
||||||
aria-label="drag to reorder"
|
aria-label="drag to reorder"
|
||||||
>⋮⋮</span>
|
>⋮⋮</span>
|
||||||
<span class="w-5 shrink-0 text-xs text-muted-foreground">{step.order_index + 1}.</span>
|
<span class="w-5 shrink-0 text-xs text-muted-foreground">{i + 1}.</span>
|
||||||
<div class="flex-1 min-w-0 px-1">
|
<div class="flex-1 min-w-0 px-1">
|
||||||
{#if step.product_id}
|
{#if step.product_id}
|
||||||
{@const product = products.find((p) => p.id === step.product_id)}
|
{@const product = products.find((p) => p.id === step.product_id)}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue