From 10146c62c3e4f18ef7ca2b1016be73cd7986e9b0 Mon Sep 17 00:00:00 2001 From: Simon Axelsson Date: Thu, 25 Jun 2026 19:38:22 +0200 Subject: [PATCH] fix: translate type/frequency in deposit page recap via entityLabel+FREQUENCY_LABEL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Values were stored as stable Swedish IDs ('Bolag', 'Engångs') but rendered raw. Now resolved through entityLabel()/FREQUENCY_LABEL + t() at render time so the recap panel respects the active locale on every re-render. Co-Authored-By: Claude Sonnet 4.6 --- app/bestall/forskott/page.tsx | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/app/bestall/forskott/page.tsx b/app/bestall/forskott/page.tsx index 6f07b07..db93b98 100644 --- a/app/bestall/forskott/page.tsx +++ b/app/bestall/forskott/page.tsx @@ -6,7 +6,10 @@ import { useEffect, useState } from "react"; import { OrderStepper } from "@/components/order-stepper"; import { useT } from "@/components/locale-provider"; import { useReveal } from "@/hooks/use-reveal"; -import { formatSEK, computeEstimate, type Estimate } from "@/lib/data"; +import { + formatSEK, computeEstimate, entityLabel, FREQUENCY_LABEL, + type Estimate, type EntityType, type Frequency, +} from "@/lib/data"; const FALLBACK: Estimate = computeEstimate({ markets: ["SE", "NO", "DK", "FI"], @@ -50,7 +53,9 @@ const RECAP_LABELS: Record = { export default function DepositPage() { const t = useT(); const [est, setEst] = useState(FALLBACK); - const [recap, setRecap] = useState>({}); + const [recap, setRecap] = useState<{ markets: string; type: EntityType; volume: string; frequency: Frequency }>({ + markets: "SE · NO · DK · FI", type: "Bolag", volume: "5 000", frequency: "Engångs", + }); const [orderId, setOrderId] = useState(null); const [paying, setPaying] = useState(false); const reveal = useReveal(); @@ -64,9 +69,9 @@ export default function DepositPage() { if (o.est) setEst(o.est); setRecap({ markets: (o.markets || []).join(" · "), - type: o.type, + type: (o.type as EntityType) || "Bolag", volume: new Intl.NumberFormat("sv-SE").format(o.volume || 0), - frequency: o.frequency, + frequency: (o.frequency as Frequency) || "Engångs", }); } } catch {} @@ -86,9 +91,9 @@ export default function DepositPage() { const c = o.config || {}; setRecap({ markets: (c.markets || []).join(" · "), - type: c.type, + type: (c.type as EntityType) || "Bolag", volume: new Intl.NumberFormat("sv-SE").format(c.volume || 0), - frequency: c.frequency, + frequency: (c.frequency as Frequency) || "Engångs", }); }) .catch(() => {}); @@ -234,16 +239,22 @@ export default function DepositPage() { {t({ en: "Your order", sv: "Din beställning" })}

- {Object.entries(recap).map(([k, v]) => ( -
-
- {RECAP_LABELS[k] ? t(RECAP_LABELS[k]) : k} -
-
- {v || "—"} -
-
- ))} +
+
{t(RECAP_LABELS.markets)}
+
{recap.markets || "—"}
+
+
+
{t(RECAP_LABELS.type)}
+
{t(entityLabel(recap.type))}
+
+
+
{t(RECAP_LABELS.volume)}
+
{recap.volume || "—"}
+
+
+
{t(RECAP_LABELS.frequency)}
+
{t(FREQUENCY_LABEL[recap.frequency] ?? { en: recap.frequency, sv: recap.frequency })}
+