feat: catalog index page + wire nav to /katalog /kallor /portal + real order journey
Configurator->POST /api/orders, deposit fetches order + PATCH in_production, header nav reaches the new pages (no orphans). New pages: katalog, katalog/[id], kallor, portal, shared states. tsc 0, build green (13 routes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { OrderStepper } from "@/components/order-stepper";
|
||||
import { useReveal } from "@/hooks/use-reveal";
|
||||
@@ -26,7 +27,10 @@ const TRUST = [
|
||||
export default function DepositPage() {
|
||||
const [est, setEst] = useState<Estimate>(FALLBACK);
|
||||
const [recap, setRecap] = useState<Record<string, string>>({});
|
||||
const [orderId, setOrderId] = useState<string | null>(null);
|
||||
const [paying, setPaying] = useState(false);
|
||||
const reveal = useReveal<HTMLDivElement>();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
@@ -42,8 +46,48 @@ export default function DepositPage() {
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
const oid = new URLSearchParams(window.location.search).get("order");
|
||||
if (oid) {
|
||||
setOrderId(oid);
|
||||
fetch(`/api/orders/${oid}`)
|
||||
.then((r) => (r.ok ? r.json() : null))
|
||||
.then((o) => {
|
||||
if (!o) return;
|
||||
setEst((prev) => ({
|
||||
...prev,
|
||||
price: Math.round((o.total_ore ?? 0) / 100) || prev.price,
|
||||
deposit: Math.round((o.deposit_ore ?? 0) / 100) || prev.deposit,
|
||||
remainder: Math.round((o.balance_ore ?? 0) / 100) || prev.remainder,
|
||||
}));
|
||||
const c = o.config || {};
|
||||
setRecap({
|
||||
Marknader: (c.markets || []).join(" · "),
|
||||
Typ: c.type,
|
||||
Volym: new Intl.NumberFormat("sv-SE").format(c.volume || 0),
|
||||
Frekvens: c.frequency,
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
}, []);
|
||||
|
||||
async function pay() {
|
||||
if (paying) return;
|
||||
setPaying(true);
|
||||
if (orderId) {
|
||||
try {
|
||||
await fetch(`/api/orders/${orderId}`, {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ status: "in_production" }),
|
||||
});
|
||||
} catch {}
|
||||
router.push(`/order/${orderId}`);
|
||||
return;
|
||||
}
|
||||
router.push("/order/SX-4471");
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-background text-foreground">
|
||||
<OrderStepper active={2} />
|
||||
@@ -188,12 +232,14 @@ export default function DepositPage() {
|
||||
</div>
|
||||
|
||||
<div className="border-t border-border p-4">
|
||||
<Link
|
||||
href="/order/SX-4471"
|
||||
className="block w-full bg-foreground py-4 text-center font-mono text-[12px] uppercase tracking-[0.12em] text-background transition-colors hover:bg-[var(--accent-red)]"
|
||||
<button
|
||||
type="button"
|
||||
onClick={pay}
|
||||
disabled={paying}
|
||||
className="block w-full bg-foreground py-4 text-center font-mono text-[12px] uppercase tracking-[0.12em] text-background transition-colors hover:bg-[var(--accent-red)] disabled:opacity-50"
|
||||
>
|
||||
Betala. Starta. →
|
||||
</Link>
|
||||
{paying ? "Startar…" : "Betala. Starta. →"}
|
||||
</button>
|
||||
<Link
|
||||
href="/bestall"
|
||||
className="mt-4 block text-center font-mono text-[11px] uppercase tracking-[0.1em] text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline"
|
||||
|
||||
+30
-6
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useMemo, useState, useEffect } from "react";
|
||||
import { OrderStepper } from "@/components/order-stepper";
|
||||
import { ProvenanceBadge } from "@/components/provenance-badge";
|
||||
@@ -49,6 +49,28 @@ export default function ConfiguratorPage() {
|
||||
} catch {}
|
||||
}, [markets, type, fieldIds, enrichmentIds, volume, frequency, confidence, formats, est]);
|
||||
|
||||
const router = useRouter();
|
||||
const [creating, setCreating] = useState(false);
|
||||
async function submit() {
|
||||
if (creating) return;
|
||||
setCreating(true);
|
||||
const config = { markets, type, fieldIds, enrichmentIds, volume, frequency, confidence, formats };
|
||||
try {
|
||||
const res = await fetch("/api/orders", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ flow: frequency === "Engångs" ? "custom" : "subscription", config }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data?.order_id) {
|
||||
router.push(`/bestall/forskott?order=${encodeURIComponent(data.order_id)}`);
|
||||
return;
|
||||
}
|
||||
} catch {}
|
||||
setCreating(false);
|
||||
router.push("/bestall/forskott");
|
||||
}
|
||||
|
||||
const toggle = (arr: string[], v: string, set: (x: string[]) => void) =>
|
||||
set(arr.includes(v) ? arr.filter((x) => x !== v) : [...arr, v]);
|
||||
|
||||
@@ -307,12 +329,14 @@ export default function ConfiguratorPage() {
|
||||
</div>
|
||||
|
||||
<div className="p-4 pt-0">
|
||||
<Link
|
||||
href="/bestall/forskott"
|
||||
className="block w-full bg-foreground py-3.5 text-center font-mono text-[12px] uppercase tracking-[0.1em] text-background transition-colors hover:bg-[var(--accent-red)]"
|
||||
<button
|
||||
type="button"
|
||||
onClick={submit}
|
||||
disabled={creating}
|
||||
className="block w-full bg-foreground py-3.5 text-center font-mono text-[12px] uppercase tracking-[0.1em] text-background transition-colors hover:bg-[var(--accent-red)] disabled:opacity-50"
|
||||
>
|
||||
Betala förskott →
|
||||
</Link>
|
||||
{creating ? "Skapar…" : "Betala förskott →"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p className="mt-3 text-center font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground">
|
||||
|
||||
@@ -0,0 +1,309 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Header } from "@/components/header";
|
||||
import { useReveal } from "@/hooks/use-reveal";
|
||||
import { CellProvenance, PROVENANCE_LEGEND } from "@/components/provenance-badge";
|
||||
import { LoadingSkeleton, EmptyState, ErrorState } from "@/components/states";
|
||||
import type { ProvLevel } from "@/lib/data";
|
||||
|
||||
// Shape of GET /api/sources (docs/04). Legal sourcing only — the transparency moat.
|
||||
interface Source {
|
||||
source_id: string;
|
||||
name: string;
|
||||
market: string;
|
||||
access: string; // api | bulk | authorized_web | licensed
|
||||
licence: string;
|
||||
cadence: string; // daily | weekly | quarterly | ...
|
||||
confidence: number; // 0..1
|
||||
}
|
||||
|
||||
// Human, terse Swedish labels for the access ladder (CLAUDE.md §1 priority order).
|
||||
const ACCESS_LABEL: Record<string, string> = {
|
||||
api: "Officiellt API",
|
||||
bulk: "Bulk / öppen data",
|
||||
authorized_web: "Auktoriserad webb",
|
||||
licensed: "Licensierad partner",
|
||||
};
|
||||
|
||||
// Confidence (0..1) → provenance level so each row carries an honest square.
|
||||
function confidenceLevel(c: number): ProvLevel {
|
||||
if (c >= 0.95) return 3;
|
||||
if (c >= 0.9) return 2;
|
||||
if (c > 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sortable columns mapped to the request: Källa · Marknad · Åtkomst · Licens · Färskhet · Konfidens.
|
||||
type SortKey = "name" | "market" | "access" | "licence" | "cadence" | "confidence";
|
||||
const COLUMNS: { key: SortKey; label: string; mono?: boolean }[] = [
|
||||
{ key: "name", label: "Källa" },
|
||||
{ key: "market", label: "Marknad", mono: true },
|
||||
{ key: "access", label: "Åtkomst", mono: true },
|
||||
{ key: "licence", label: "Licens" },
|
||||
{ key: "cadence", label: "Färskhet", mono: true },
|
||||
{ key: "confidence", label: "Konfidens", mono: true },
|
||||
];
|
||||
|
||||
const ALL = "Alla";
|
||||
|
||||
export default function SourcesPage() {
|
||||
const [sources, setSources] = useState<Source[] | null>(null);
|
||||
const [status, setStatus] = useState<"loading" | "ready" | "error">("loading");
|
||||
const [reloadKey, setReloadKey] = useState(0);
|
||||
|
||||
const [market, setMarket] = useState<string>(ALL);
|
||||
const [access, setAccess] = useState<string>(ALL);
|
||||
const [sort, setSort] = useState<{ key: SortKey; dir: 1 | -1 }>({ key: "confidence", dir: -1 });
|
||||
|
||||
const ref = useReveal<HTMLElement>();
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
setStatus("loading");
|
||||
fetch("/api/sources")
|
||||
.then((r) => {
|
||||
if (!r.ok) throw new Error(String(r.status));
|
||||
return r.json();
|
||||
})
|
||||
.then((data: Source[]) => {
|
||||
if (cancelled) return;
|
||||
setSources(Array.isArray(data) ? data : []);
|
||||
setStatus("ready");
|
||||
})
|
||||
.catch(() => {
|
||||
if (cancelled) return;
|
||||
setSources(null);
|
||||
setStatus("error");
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [reloadKey]);
|
||||
|
||||
const markets = useMemo(() => {
|
||||
if (!sources) return [ALL];
|
||||
return [ALL, ...Array.from(new Set(sources.map((s) => s.market)))];
|
||||
}, [sources]);
|
||||
|
||||
const accesses = useMemo(() => {
|
||||
if (!sources) return [ALL];
|
||||
return [ALL, ...Array.from(new Set(sources.map((s) => s.access)))];
|
||||
}, [sources]);
|
||||
|
||||
const rows = useMemo(() => {
|
||||
if (!sources) return [];
|
||||
const filtered = sources.filter(
|
||||
(s) => (market === ALL || s.market === market) && (access === ALL || s.access === access),
|
||||
);
|
||||
const { key, dir } = sort;
|
||||
return [...filtered].sort((a, b) => {
|
||||
const av = a[key];
|
||||
const bv = b[key];
|
||||
if (typeof av === "number" && typeof bv === "number") return (av - bv) * dir;
|
||||
return String(av).localeCompare(String(bv), "sv") * dir;
|
||||
});
|
||||
}, [sources, market, access, sort]);
|
||||
|
||||
const setSortKey = (key: SortKey) =>
|
||||
setSort((p) => (p.key === key ? { key, dir: (p.dir * -1) as 1 | -1 } : { key, dir: key === "confidence" ? -1 : 1 }));
|
||||
|
||||
const Pill = ({
|
||||
active,
|
||||
onClick,
|
||||
children,
|
||||
}: {
|
||||
active: boolean;
|
||||
onClick: () => void;
|
||||
children: React.ReactNode;
|
||||
}) => (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className="border px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.08em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
style={{
|
||||
borderColor: active ? "var(--foreground)" : "var(--border)",
|
||||
backgroundColor: active ? "var(--foreground)" : "transparent",
|
||||
color: active ? "var(--background)" : "var(--foreground)",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-background text-foreground">
|
||||
<Header />
|
||||
|
||||
{/* masthead — oversized faint numeral as graphic texture */}
|
||||
<section ref={ref} className="relative overflow-hidden border-b border-border">
|
||||
<span
|
||||
aria-hidden
|
||||
className="pointer-events-none absolute -right-3 -top-8 select-none font-mono text-[clamp(7rem,22vw,15rem)] font-medium leading-none tracking-[-0.05em] text-secondary"
|
||||
>
|
||||
05
|
||||
</span>
|
||||
<div className="relative mx-auto max-w-[80rem] px-6 py-16 md:py-24">
|
||||
<div className="reveal flex items-center gap-3">
|
||||
<span aria-hidden className="animate-float inline-block h-2 w-2" style={{ backgroundColor: "var(--accent-red)" }} />
|
||||
<p className="font-mono text-[11px] uppercase tracking-[0.16em] text-muted-foreground">Källkarta</p>
|
||||
</div>
|
||||
<h1 className="reveal delay-1 mt-6 max-w-3xl text-[clamp(2.4rem,6vw,4.5rem)] font-medium leading-[0.95] tracking-[-0.035em]">
|
||||
Varje fält.
|
||||
<br />
|
||||
Varje källa.
|
||||
</h1>
|
||||
<p className="reveal delay-2 mt-6 max-w-[42ch] font-mono text-[11px] uppercase tracking-[0.1em] text-muted-foreground">
|
||||
Officiellt först. Sen öppen data. Sen licens. Aldrig gissat.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="mx-auto max-w-[80rem] px-6 py-12">
|
||||
{/* legend — the 4 provenance squares */}
|
||||
<div className="reveal mb-8 flex flex-wrap items-center gap-x-6 gap-y-3 border-b border-border pb-6">
|
||||
<span className="font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">Härkomst</span>
|
||||
{PROVENANCE_LEGEND.map((l) => (
|
||||
<span key={l.level} className="inline-flex items-center gap-2 font-mono text-[10.5px] tracking-[0.02em] text-muted-foreground">
|
||||
<span
|
||||
aria-hidden
|
||||
className="inline-block h-[9px] w-[9px]"
|
||||
style={{
|
||||
backgroundColor: l.level === 0 ? "transparent" : `var(--prov-${l.level})`,
|
||||
border: l.level === 0 ? "1px solid var(--prov-0)" : "none",
|
||||
}}
|
||||
/>
|
||||
{l.text}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* filters — pills by Marknad / Åtkomst (Typ) */}
|
||||
{status === "ready" && sources && sources.length > 0 ? (
|
||||
<div className="reveal mb-8 flex flex-col gap-5">
|
||||
<div>
|
||||
<p className="mb-3 font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">Marknad</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{markets.map((m) => (
|
||||
<Pill key={m} active={market === m} onClick={() => setMarket(m)}>
|
||||
{m === ALL ? ALL : m === "global" ? "Global" : m}
|
||||
</Pill>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p className="mb-3 font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">Typ av åtkomst</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{accesses.map((a) => (
|
||||
<Pill key={a} active={access === a} onClick={() => setAccess(a)}>
|
||||
{a === ALL ? ALL : ACCESS_LABEL[a] ?? a}
|
||||
</Pill>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{/* states + table */}
|
||||
{status === "loading" ? <LoadingSkeleton rows={9} /> : null}
|
||||
|
||||
{status === "error" ? (
|
||||
<ErrorState title="Kunde inte läsa källkartan" onRetry={() => setReloadKey((k) => k + 1)} />
|
||||
) : null}
|
||||
|
||||
{status === "ready" && (!sources || sources.length === 0) ? (
|
||||
<EmptyState
|
||||
title="Inga källor ännu"
|
||||
line="Källkartan fylls när första marknaden går live. Norden först."
|
||||
ctaHref="/bestall"
|
||||
ctaLabel="Bygg ett jobb"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{status === "ready" && sources && sources.length > 0 && rows.length === 0 ? (
|
||||
<EmptyState
|
||||
title="Inget i den vyn"
|
||||
line="Inga källor matchar valt filter. Nollställ och försök igen."
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{status === "ready" && rows.length > 0 ? (
|
||||
<div className="reveal-fade">
|
||||
<div className="overflow-x-auto border border-border">
|
||||
<table className="w-full border-collapse text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border bg-secondary">
|
||||
{COLUMNS.map((c) => {
|
||||
const isSorted = sort.key === c.key;
|
||||
return (
|
||||
<th
|
||||
key={c.key}
|
||||
scope="col"
|
||||
aria-sort={isSorted ? (sort.dir === 1 ? "ascending" : "descending") : "none"}
|
||||
className={`px-3 py-2.5 text-left ${c.key === "confidence" ? "text-right" : ""}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSortKey(c.key)}
|
||||
className={`group inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.1em] transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background ${
|
||||
isSorted ? "text-foreground" : "text-muted-foreground"
|
||||
}`}
|
||||
>
|
||||
{c.label}
|
||||
<span aria-hidden className="text-[9px] tabular-nums">
|
||||
{isSorted ? (sort.dir === 1 ? "↑" : "↓") : "·"}
|
||||
</span>
|
||||
</button>
|
||||
</th>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((s) => {
|
||||
const level = confidenceLevel(s.confidence);
|
||||
return (
|
||||
<tr
|
||||
key={s.source_id}
|
||||
className="border-b border-border transition-colors last:border-b-0 hover:bg-secondary/60"
|
||||
>
|
||||
<td className="px-3 py-3 align-top">
|
||||
<span className="text-[15px] tracking-tight">{s.name}</span>
|
||||
<span className="ml-2 font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground/60">
|
||||
{s.source_id}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-3 py-3 align-top font-mono text-xs uppercase tracking-[0.06em]">
|
||||
{s.market === "global" ? "Global" : s.market}
|
||||
</td>
|
||||
<td className="px-3 py-3 align-top font-mono text-[11px] uppercase tracking-[0.04em] text-muted-foreground">
|
||||
{ACCESS_LABEL[s.access] ?? s.access}
|
||||
</td>
|
||||
<td className="px-3 py-3 align-top text-xs text-muted-foreground">{s.licence}</td>
|
||||
<td className="px-3 py-3 align-top font-mono text-[11px] uppercase tracking-[0.04em]">
|
||||
{s.cadence}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-3 text-right align-top font-mono text-xs tabular-nums">
|
||||
{Math.round(s.confidence * 100)}%
|
||||
<CellProvenance level={level} />
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="mt-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<p className="font-mono text-[10.5px] uppercase tracking-[0.08em] text-muted-foreground">
|
||||
{rows.length} källor · varje fält bär sin härkomst
|
||||
</p>
|
||||
<p className="font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground/70">
|
||||
Licensvillkor verifieras innan användning
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,629 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { Header } from "@/components/header";
|
||||
import { DataArtifact } from "@/components/data-artifact";
|
||||
import { ProvenanceBadge, CellProvenance, PROVENANCE_LEGEND } from "@/components/provenance-badge";
|
||||
import { LoadingSkeleton, EmptyState, ErrorState } from "@/components/states";
|
||||
import { useReveal } from "@/hooks/use-reveal";
|
||||
import { FIELDS, SAMPLE_ROWS, MARKETS, formatSEK, type ProvLevel } from "@/lib/data";
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Inline catalog. No detail API yet — keyed by slugified id with a safe fallback.
|
||||
// Mirrors the slugs that the catalog cards (featured-products-section) imply.
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
interface Dataset {
|
||||
id: string;
|
||||
markets: string;
|
||||
marketCodes: string[];
|
||||
title: string;
|
||||
blurb: string;
|
||||
count: string;
|
||||
rows: number;
|
||||
freshness: string;
|
||||
level: ProvLevel;
|
||||
source: string;
|
||||
cat: string;
|
||||
price: number;
|
||||
artifact: "table" | "map" | "schema" | "chart";
|
||||
}
|
||||
|
||||
const CATALOG: Dataset[] = [
|
||||
{
|
||||
id: "nordisk-bolagsdata",
|
||||
markets: "SE · NO · DK · FI",
|
||||
marketCodes: ["SE", "NO", "DK", "FI"],
|
||||
title: "Nordisk bolagsdata",
|
||||
blurb: "Officiella register. Per fält.",
|
||||
count: "4,9M poster",
|
||||
rows: 4900000,
|
||||
freshness: "daglig",
|
||||
level: 3,
|
||||
source: "GLEIF · Brreg",
|
||||
cat: "Bolag",
|
||||
price: 18400,
|
||||
artifact: "table",
|
||||
},
|
||||
{
|
||||
id: "beslutsfattare-tech",
|
||||
markets: "SE · NO · DK · FI",
|
||||
marketCodes: ["SE", "NO", "DK", "FI"],
|
||||
title: "Beslutsfattare i tech",
|
||||
blurb: "Roll och väg. Källa per fält.",
|
||||
count: "182k poster",
|
||||
rows: 182000,
|
||||
freshness: "veckovis",
|
||||
level: 1,
|
||||
source: "publik webb",
|
||||
cat: "Beslutsfattare",
|
||||
price: 9600,
|
||||
artifact: "schema",
|
||||
},
|
||||
{
|
||||
id: "fordon-flotta",
|
||||
markets: "SE",
|
||||
marketCodes: ["SE"],
|
||||
title: "Fordon & flotta",
|
||||
blurb: "Tekniska data. VehIQ-synergin.",
|
||||
count: "6,1M poster",
|
||||
rows: 6100000,
|
||||
freshness: "daglig",
|
||||
level: 2,
|
||||
source: "register",
|
||||
cat: "Fordon",
|
||||
price: 12200,
|
||||
artifact: "map",
|
||||
},
|
||||
{
|
||||
id: "finansiella-serier",
|
||||
markets: "SE · NO · DK · FI",
|
||||
marketCodes: ["SE", "NO", "DK", "FI"],
|
||||
title: "Finansiella serier",
|
||||
blurb: "Omsättning, resultat, nyckeltal.",
|
||||
count: "12 år",
|
||||
rows: 240000,
|
||||
freshness: "årlig",
|
||||
level: 2,
|
||||
source: "register",
|
||||
cat: "Finansiellt",
|
||||
price: 14800,
|
||||
artifact: "chart",
|
||||
},
|
||||
];
|
||||
|
||||
const TABS = ["Översikt", "Exempeldata", "Kvalitet", "Schema", "Täckning", "Pris"] as const;
|
||||
type Tab = (typeof TABS)[number];
|
||||
|
||||
function findDataset(raw: string | undefined): Dataset | undefined {
|
||||
if (!raw) return undefined;
|
||||
const slug = decodeURIComponent(raw).toLowerCase();
|
||||
return CATALOG.find((d) => d.id === slug);
|
||||
}
|
||||
|
||||
export default function DatasetDetailPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const reveal = useReveal<HTMLDivElement>();
|
||||
|
||||
const [status, setStatus] = useState<"loading" | "ready" | "empty" | "error">("loading");
|
||||
const [dataset, setDataset] = useState<Dataset | null>(null);
|
||||
const [tab, setTab] = useState<Tab>("Översikt");
|
||||
const attempt = useRef(0);
|
||||
|
||||
// Simulated detail fetch. Replace with GET /catalog/:id when the API lands.
|
||||
const load = useCallback(() => {
|
||||
setStatus("loading");
|
||||
attempt.current += 1;
|
||||
const run = attempt.current;
|
||||
const t = setTimeout(() => {
|
||||
if (run !== attempt.current) return;
|
||||
const hit = findDataset(id);
|
||||
if (hit) {
|
||||
setDataset(hit);
|
||||
setStatus("ready");
|
||||
} else {
|
||||
// Known id-space, no match → empty (not an error).
|
||||
setDataset(null);
|
||||
setStatus("empty");
|
||||
}
|
||||
}, 540);
|
||||
return () => clearTimeout(t);
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
const cleanup = load();
|
||||
return cleanup;
|
||||
}, [load]);
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-background text-foreground">
|
||||
<Header />
|
||||
|
||||
<div ref={reveal} className="mx-auto max-w-[80rem] px-6">
|
||||
{status === "loading" ? (
|
||||
<section className="py-24">
|
||||
<p className="reveal font-mono text-[11px] uppercase tracking-[0.18em] text-muted-foreground">
|
||||
Katalog — laddar
|
||||
</p>
|
||||
<div className="mt-10">
|
||||
<LoadingSkeleton rows={6} />
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{status === "error" ? (
|
||||
<section className="py-24">
|
||||
<ErrorState title="Kunde inte hämta datasetet" onRetry={load} />
|
||||
<div className="mt-10">
|
||||
<Link
|
||||
href="/#katalog"
|
||||
className="font-mono text-[11px] uppercase tracking-[0.1em] text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
|
||||
>
|
||||
← Till katalogen
|
||||
</Link>
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{status === "empty" ? (
|
||||
<section className="py-24">
|
||||
<EmptyState
|
||||
title="Datasetet finns inte"
|
||||
line="Inget i katalogen matchar den länken. Bygg jobbet själv eller gå tillbaka."
|
||||
ctaHref="/bestall"
|
||||
ctaLabel="Komponera ett jobb"
|
||||
/>
|
||||
<div className="mt-10">
|
||||
<Link
|
||||
href="/#katalog"
|
||||
className="font-mono text-[11px] uppercase tracking-[0.1em] text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
|
||||
>
|
||||
← Till katalogen
|
||||
</Link>
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{status === "ready" && dataset ? <DatasetView d={dataset} tab={tab} setTab={setTab} /> : null}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
function DatasetView({
|
||||
d,
|
||||
tab,
|
||||
setTab,
|
||||
}: {
|
||||
d: Dataset;
|
||||
tab: Tab;
|
||||
setTab: (t: Tab) => void;
|
||||
}) {
|
||||
const deposit = Math.round(d.price / 2);
|
||||
const remainder = d.price - deposit;
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* breadcrumb */}
|
||||
<div className="reveal flex items-center gap-2 border-b border-border py-4 font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground">
|
||||
<Link href="/#katalog" className="underline-offset-4 transition-colors hover:text-foreground hover:underline">
|
||||
Katalog
|
||||
</Link>
|
||||
<span className="text-border">/</span>
|
||||
<span className="text-foreground">{d.title}</span>
|
||||
</div>
|
||||
|
||||
{/* masthead — oversized faint numeral as texture */}
|
||||
<header className="relative border-b border-border py-16 md:py-20">
|
||||
<span
|
||||
aria-hidden
|
||||
className="pointer-events-none absolute -top-6 right-0 select-none font-mono text-[clamp(7rem,18vw,15rem)] font-medium leading-none tracking-[-0.04em] text-foreground/[0.04]"
|
||||
>
|
||||
02
|
||||
</span>
|
||||
<p className="reveal font-mono text-[11px] uppercase tracking-[0.18em] text-muted-foreground">
|
||||
Katalog — {d.cat}
|
||||
</p>
|
||||
<h1 className="reveal delay-1 mt-5 max-w-[16ch] text-[clamp(2.6rem,7vw,5.5rem)] font-medium leading-[0.95] tracking-[-0.035em]">
|
||||
{d.title}.
|
||||
</h1>
|
||||
<p className="reveal delay-2 mt-5 max-w-md font-mono text-sm text-muted-foreground">{d.blurb}</p>
|
||||
|
||||
<div className="reveal delay-3 mt-8 flex flex-wrap items-center gap-3">
|
||||
<ProvenanceBadge level={d.level} source={d.source} freshness={d.freshness} />
|
||||
<span className="font-mono text-[11px] uppercase tracking-[0.1em] text-muted-foreground">
|
||||
{d.markets}
|
||||
</span>
|
||||
<span className="text-border">·</span>
|
||||
<span className="font-mono text-[11px] uppercase tracking-[0.1em] text-foreground">{d.count}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* two columns — content + sticky order rail */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-[1fr_340px]">
|
||||
<div className="reveal-left delay-1 lg:border-r lg:border-border">
|
||||
{/* tabs — shared baseline, single active marker */}
|
||||
<nav
|
||||
aria-label="Vyer"
|
||||
className="sticky top-16 z-30 -mx-px flex flex-wrap gap-px border-b border-border bg-border"
|
||||
>
|
||||
{TABS.map((t) => {
|
||||
const active = t === tab;
|
||||
return (
|
||||
<button
|
||||
key={t}
|
||||
type="button"
|
||||
onClick={() => setTab(t)}
|
||||
aria-current={active ? "page" : undefined}
|
||||
className="flex-1 bg-background px-4 py-3.5 font-mono text-[11px] uppercase tracking-[0.1em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
style={{
|
||||
backgroundColor: active ? "var(--foreground)" : "var(--background)",
|
||||
color: active ? "var(--background)" : "var(--muted-foreground)",
|
||||
}}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
<div className="px-1 py-10 lg:pr-8">
|
||||
{tab === "Översikt" ? <OverviewTab d={d} /> : null}
|
||||
{tab === "Exempeldata" ? <SampleTab d={d} /> : null}
|
||||
{tab === "Kvalitet" ? <QualityTab d={d} /> : null}
|
||||
{tab === "Schema" ? <SchemaTab /> : null}
|
||||
{tab === "Täckning" ? <CoverageTab d={d} /> : null}
|
||||
{tab === "Pris" ? <PriceTab price={d.price} deposit={deposit} remainder={remainder} /> : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* sticky right — order panel */}
|
||||
<aside className="reveal-right delay-2">
|
||||
<div className="lg:sticky lg:top-20 lg:py-10 lg:pl-8">
|
||||
<div className="border border-border bg-background">
|
||||
<div className="border-b border-border px-6 py-5">
|
||||
<p className="font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">Pris</p>
|
||||
<p className="mt-3 text-[clamp(2rem,4vw,2.6rem)] font-medium leading-none tracking-[-0.03em] tabular-nums">
|
||||
{formatSEK(d.price)}
|
||||
</p>
|
||||
<p className="mt-3 font-mono text-[11px] text-muted-foreground">Engångsleverans · per fält</p>
|
||||
</div>
|
||||
|
||||
{/* 50% deposit ledger */}
|
||||
<div className="border-b border-border px-6 py-5">
|
||||
<div className="flex items-baseline justify-between font-mono text-[12px]">
|
||||
<span className="uppercase tracking-[0.1em] text-muted-foreground">Förskott 50 %</span>
|
||||
<span className="tabular-nums text-foreground">{formatSEK(deposit)}</span>
|
||||
</div>
|
||||
<div className="mt-3 flex items-baseline justify-between font-mono text-[12px]">
|
||||
<span className="uppercase tracking-[0.1em] text-muted-foreground">Vid godkänt</span>
|
||||
<span className="tabular-nums text-muted-foreground">{formatSEK(remainder)}</span>
|
||||
</div>
|
||||
<p className="mt-4 border-t border-border pt-4 font-mono text-[10.5px] leading-relaxed text-muted-foreground">
|
||||
Resterande 50 % hålls i escrow. Släpps först när du godkänt resultatet.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* the one red per screen */}
|
||||
<div className="px-6 py-6">
|
||||
<Link
|
||||
href="/bestall"
|
||||
className="group flex items-center justify-center gap-3 px-5 py-3.5 font-mono text-[12px] uppercase tracking-[0.12em] text-background transition-opacity duration-200 hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
style={{ backgroundColor: "var(--accent-red)" }}
|
||||
>
|
||||
Beställ
|
||||
<span aria-hidden className="transition-transform duration-300 group-hover:translate-x-1">
|
||||
→
|
||||
</span>
|
||||
</Link>
|
||||
<p className="mt-4 text-center font-mono text-[10px] uppercase tracking-[0.1em] text-muted-foreground">
|
||||
Inget binder förrän förskott
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* honest disclosure */}
|
||||
<p className="mt-6 font-mono text-[10.5px] leading-relaxed text-muted-foreground">
|
||||
Saknade fält levereras som “ej tillgänglig / licens”. Vi gissar aldrig.
|
||||
</p>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Tab bodies ───────────────────────────────────────────────────────────────
|
||||
|
||||
function SectionHead({ num, kicker }: { num: string; kicker: string }) {
|
||||
return (
|
||||
<div className="flex items-baseline justify-between border-b border-border pb-4">
|
||||
<p className="font-mono text-[11px] uppercase tracking-[0.18em] text-muted-foreground">{kicker}</p>
|
||||
<span aria-hidden className="font-mono text-[11px] tabular-nums text-foreground/20">
|
||||
{num}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function OverviewTab({ d }: { d: Dataset }) {
|
||||
const stats: [string, string][] = [
|
||||
[d.count, "omfattning"],
|
||||
[`${d.marketCodes.length}`, "marknader"],
|
||||
[d.freshness, "uppdatering"],
|
||||
];
|
||||
return (
|
||||
<div>
|
||||
<SectionHead num="01" kicker="Översikt" />
|
||||
<p className="mt-8 max-w-xl text-pretty text-[17px] leading-relaxed">
|
||||
Strukturerat per fält. Varje värde bär källa, färskhet och konfidens — så att du ser var det
|
||||
kommer ifrån innan du litar på det.
|
||||
</p>
|
||||
|
||||
<div className="mt-10 grid grid-cols-1 gap-px border border-border bg-border sm:grid-cols-3">
|
||||
{stats.map(([n, l], i) => (
|
||||
<div key={l} className="bg-background p-6">
|
||||
<p
|
||||
className="text-[clamp(1.6rem,3vw,2.2rem)] font-medium leading-none tracking-[-0.02em] tabular-nums"
|
||||
style={i === 0 ? { color: "var(--accent-red)" } : undefined}
|
||||
>
|
||||
{n}
|
||||
</p>
|
||||
<p className="mt-3 font-mono text-[10px] uppercase tracking-[0.1em] text-muted-foreground">{l}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-10">
|
||||
<DataArtifact variant={d.artifact} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SampleTab({ d }: { d: Dataset }) {
|
||||
return (
|
||||
<div>
|
||||
<SectionHead num="02" kicker="Exempeldata" />
|
||||
<p className="mt-8 font-mono text-[12px] text-muted-foreground">
|
||||
Fem rader. Provenans per cell.
|
||||
</p>
|
||||
|
||||
{/* primary view — generative table artifact */}
|
||||
<div className="mt-8">
|
||||
<DataArtifact variant="table" />
|
||||
</div>
|
||||
|
||||
{/* concrete sample rows from lib/data */}
|
||||
<div className="mt-px overflow-x-auto border border-border">
|
||||
<table className="w-full border-collapse">
|
||||
<thead>
|
||||
<tr className="border-b border-border">
|
||||
{["Org.nr", "Bolag", "Säte", "Anställda", "Oms (tkr)", "E-post"].map((h) => (
|
||||
<th
|
||||
key={h}
|
||||
className="whitespace-nowrap px-4 py-3 text-left font-mono text-[10px] uppercase tracking-[0.12em] text-muted-foreground"
|
||||
>
|
||||
{h}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{SAMPLE_ROWS.map((r) => (
|
||||
<tr key={r.orgnr} className="border-b border-border last:border-b-0 transition-colors hover:bg-secondary/40">
|
||||
<td className="whitespace-nowrap px-4 py-3 font-mono text-[12px] tabular-nums text-muted-foreground">
|
||||
{r.orgnr}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-4 py-3 text-[14px] tracking-tight">{r.bolag}</td>
|
||||
<td className="whitespace-nowrap px-4 py-3 text-[13px] text-muted-foreground">{r.sate}</td>
|
||||
<td className="whitespace-nowrap px-4 py-3 text-right font-mono text-[12px] tabular-nums">
|
||||
{new Intl.NumberFormat("sv-SE").format(r.anstallda)}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-4 py-3 text-right font-mono text-[12px] tabular-nums text-muted-foreground">
|
||||
{new Intl.NumberFormat("sv-SE").format(r.oms)}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-4 py-3 font-mono text-[12px]">
|
||||
{r.epost ? (
|
||||
<span className="text-foreground">{r.epost}</span>
|
||||
) : (
|
||||
<span className="text-muted-foreground">ej tillgänglig</span>
|
||||
)}
|
||||
<CellProvenance level={r.epostLevel} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p className="mt-4 font-mono text-[10.5px] text-muted-foreground">
|
||||
Tom = licens krävs i marknaden. Inget gissat. Källa: {d.source}.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function QualityTab({ d }: { d: Dataset }) {
|
||||
const metrics: [string, number, ProvLevel][] = [
|
||||
["Identifierad entitet", 99, 3],
|
||||
["LEI-länkad", 92, 3],
|
||||
["Dubbletter borttagna", 100, 3],
|
||||
["E-post verifierad (MX)", 71, 2],
|
||||
["Källor överens", 88, d.level],
|
||||
];
|
||||
return (
|
||||
<div>
|
||||
<SectionHead num="03" kicker="Kvalitet" />
|
||||
<p className="mt-8 max-w-xl text-pretty text-[17px] leading-relaxed">
|
||||
Mätt, inte påstått. Varje rad passerar expectations, dedup och en konfidenströskel innan den
|
||||
levereras.
|
||||
</p>
|
||||
|
||||
<div className="mt-10 flex flex-col gap-5">
|
||||
{metrics.map(([label, pct, level]) => (
|
||||
<div key={label} className="flex items-center gap-4">
|
||||
<span className="w-52 shrink-0 text-[14px] tracking-tight">{label}</span>
|
||||
<div className="h-px flex-1 bg-border">
|
||||
<div
|
||||
className="h-px transition-all duration-500"
|
||||
style={{
|
||||
width: `${pct}%`,
|
||||
backgroundColor: level >= 3 ? "var(--prov-3)" : level >= 2 ? "var(--prov-2)" : "var(--prov-1)",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<span className="w-12 text-right font-mono text-[12px] tabular-nums text-muted-foreground">{pct}%</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* provenance legend */}
|
||||
<div className="mt-12 border-t border-border pt-6">
|
||||
<p className="font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">Härkomst</p>
|
||||
<div className="mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
{PROVENANCE_LEGEND.map((p) => (
|
||||
<div key={p.level} className="flex items-center gap-3 font-mono text-[11px] text-muted-foreground">
|
||||
<span
|
||||
aria-hidden
|
||||
className="inline-block h-[9px] w-[9px]"
|
||||
style={{
|
||||
backgroundColor: p.level === 0 ? "transparent" : `var(--prov-${p.level})`,
|
||||
border: p.level === 0 ? "1px solid var(--prov-0)" : "none",
|
||||
}}
|
||||
/>
|
||||
{p.text}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SchemaTab() {
|
||||
return (
|
||||
<div>
|
||||
<SectionHead num="04" kicker="Schema" />
|
||||
<p className="mt-8 font-mono text-[12px] text-muted-foreground">Fält, källa, vikt. Per fält.</p>
|
||||
|
||||
<div className="mt-8">
|
||||
<DataArtifact variant="schema" />
|
||||
</div>
|
||||
|
||||
<div className="mt-px border border-border">
|
||||
{FIELDS.map((f, i) => (
|
||||
<div
|
||||
key={f.id}
|
||||
className="flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-4 transition-colors last:border-b-0 hover:bg-secondary/40"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-baseline gap-3">
|
||||
<span className="font-mono text-[10px] tabular-nums text-muted-foreground">
|
||||
{String(i + 1).padStart(2, "0")}
|
||||
</span>
|
||||
<span className="text-[15px] tracking-tight">{f.name}</span>
|
||||
{f.locked ? (
|
||||
<span className="font-mono text-[9px] uppercase tracking-[0.12em] text-muted-foreground">låst</span>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="mt-1 pl-7 font-mono text-[11px] text-muted-foreground">{f.sub}</p>
|
||||
</div>
|
||||
<ProvenanceBadge level={f.level} source={f.source} freshness={f.freshness} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function CoverageTab({ d }: { d: Dataset }) {
|
||||
const inSet = (code: string) => d.marketCodes.includes(code);
|
||||
return (
|
||||
<div>
|
||||
<SectionHead num="05" kicker="Täckning" />
|
||||
<p className="mt-8 max-w-xl text-pretty text-[17px] leading-relaxed">
|
||||
Var datasetet lever idag. Markerade marknader ingår — resten är kommande.
|
||||
</p>
|
||||
|
||||
<div className="mt-8">
|
||||
<DataArtifact variant="map" />
|
||||
</div>
|
||||
|
||||
<div className="mt-px grid grid-cols-[repeat(auto-fill,minmax(108px,1fr))] gap-px border border-border bg-border">
|
||||
{MARKETS.slice(0, 12).map((m) => {
|
||||
const included = inSet(m.code) && m.live;
|
||||
return (
|
||||
<div
|
||||
key={m.code}
|
||||
className="relative bg-background p-4 transition-opacity duration-300"
|
||||
style={{ opacity: included ? 1 : 0.4 }}
|
||||
>
|
||||
<div className="flex items-baseline justify-between">
|
||||
<p className="font-mono text-sm font-semibold tracking-tight">{m.code}</p>
|
||||
{included ? (
|
||||
<span
|
||||
aria-hidden
|
||||
className="inline-block h-[7px] w-[7px]"
|
||||
style={{ backgroundColor: "var(--prov-3)" }}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="mt-1 font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground">
|
||||
{included ? `${m.coverage}%` : m.live ? "ej i set" : "kommande"}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PriceTab({ price, deposit, remainder }: { price: number; deposit: number; remainder: number }) {
|
||||
const lines: [string, string, boolean][] = [
|
||||
["Listpris", formatSEK(price), false],
|
||||
["Förskott 50 % — startar produktion", formatSEK(deposit), true],
|
||||
["Vid godkänt — släpps ur escrow", formatSEK(remainder), false],
|
||||
];
|
||||
return (
|
||||
<div>
|
||||
<SectionHead num="06" kicker="Pris" />
|
||||
<p className="mt-8 max-w-xl text-pretty text-[17px] leading-relaxed">
|
||||
Halva nu, halva vid godkänt. Resterande hålls i escrow tills du validerat resultatet.
|
||||
</p>
|
||||
|
||||
<div className="mt-10 border border-border">
|
||||
{lines.map(([label, val, hot]) => (
|
||||
<div
|
||||
key={label}
|
||||
className="flex items-baseline justify-between gap-4 border-b border-border px-5 py-5 last:border-b-0"
|
||||
>
|
||||
<span className="font-mono text-[12px] uppercase tracking-[0.08em] text-muted-foreground">{label}</span>
|
||||
<span
|
||||
className="font-mono text-[15px] tabular-nums"
|
||||
style={hot ? { color: "var(--accent-red)" } : { color: "var(--foreground)" }}
|
||||
>
|
||||
{val}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-10">
|
||||
<Link
|
||||
href="/bestall"
|
||||
className="group inline-flex items-center gap-3 border border-foreground bg-background px-7 py-4 font-mono text-[12px] uppercase tracking-[0.12em] text-foreground transition-colors duration-200 hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
Komponera & beställ
|
||||
<span aria-hidden className="transition-transform duration-300 group-hover:translate-x-1">
|
||||
→
|
||||
</span>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Header } from "@/components/header";
|
||||
import { useReveal } from "@/hooks/use-reveal";
|
||||
import { CellProvenance } from "@/components/provenance-badge";
|
||||
import { LoadingSkeleton, EmptyState, ErrorState } from "@/components/states";
|
||||
import { formatSEK, type ProvLevel } from "@/lib/data";
|
||||
|
||||
interface CatalogItem {
|
||||
id: string;
|
||||
title: string;
|
||||
markets: string[];
|
||||
entity_type: string;
|
||||
count: number;
|
||||
updated: string;
|
||||
price_ore: number;
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
const FILTERS: { key: string; label: string }[] = [
|
||||
{ key: "all", label: "Alla" },
|
||||
{ key: "company", label: "Bolag" },
|
||||
{ key: "contact", label: "Beslutsfattare" },
|
||||
{ key: "vehicle", label: "Fordon" },
|
||||
{ key: "financials", label: "Finansiellt" },
|
||||
];
|
||||
|
||||
function level(c: number): ProvLevel {
|
||||
if (c >= 0.9) return 3;
|
||||
if (c >= 0.8) return 2;
|
||||
if (c >= 0.5) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
export default function CatalogPage() {
|
||||
const ref = useReveal<HTMLDivElement>();
|
||||
const [items, setItems] = useState<CatalogItem[] | null>(null);
|
||||
const [err, setErr] = useState(false);
|
||||
const [filter, setFilter] = useState("all");
|
||||
const [q, setQ] = useState("");
|
||||
|
||||
function load() {
|
||||
setErr(false);
|
||||
setItems(null);
|
||||
fetch("/api/catalog")
|
||||
.then((r) => (r.ok ? r.json() : Promise.reject()))
|
||||
.then(setItems)
|
||||
.catch(() => setErr(true));
|
||||
}
|
||||
useEffect(load, []);
|
||||
|
||||
const shown = useMemo(() => {
|
||||
if (!items) return [];
|
||||
return items.filter(
|
||||
(d) =>
|
||||
(filter === "all" || d.entity_type === filter) &&
|
||||
(q === "" || d.title.toLowerCase().includes(q.toLowerCase())),
|
||||
);
|
||||
}, [items, filter, q]);
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-background text-foreground">
|
||||
<Header />
|
||||
<div ref={ref} className="mx-auto max-w-[80rem] px-6 py-20">
|
||||
<header className="relative border-b border-border pb-8">
|
||||
<span aria-hidden className="pointer-events-none absolute -top-6 right-0 select-none font-mono text-[clamp(6rem,16vw,13rem)] font-medium leading-none tracking-[-0.04em] text-foreground/[0.04]">02</span>
|
||||
<p className="reveal font-mono text-[11px] uppercase tracking-[0.18em] text-muted-foreground">02 — Katalog</p>
|
||||
<h1 className="reveal delay-1 mt-5 max-w-[16ch] text-[clamp(2.6rem,7vw,5.5rem)] font-medium leading-[0.95] tracking-[-0.035em]">Färdig data. Direkt.</h1>
|
||||
</header>
|
||||
|
||||
<div className="reveal delay-2 mt-10 flex flex-wrap items-center justify-between gap-4">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{FILTERS.map((f) => (
|
||||
<button
|
||||
key={f.key}
|
||||
onClick={() => setFilter(f.key)}
|
||||
className="border px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.08em] transition-colors"
|
||||
style={{
|
||||
borderColor: filter === f.key ? "var(--foreground)" : "var(--border)",
|
||||
backgroundColor: filter === f.key ? "var(--foreground)" : "transparent",
|
||||
color: filter === f.key ? "var(--background)" : "var(--foreground)",
|
||||
}}
|
||||
>
|
||||
{f.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<input
|
||||
value={q}
|
||||
onChange={(e) => setQ(e.target.value)}
|
||||
placeholder="Sök dataset…"
|
||||
className="w-full max-w-xs border border-border bg-input px-3 py-2 font-mono text-xs outline-none focus:border-foreground sm:w-auto"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mt-10">
|
||||
{err ? (
|
||||
<ErrorState onRetry={load} />
|
||||
) : items === null ? (
|
||||
<LoadingSkeleton rows={6} />
|
||||
) : shown.length === 0 ? (
|
||||
<EmptyState title="Inga träffar." line="Bredda filtret." ctaHref="/bestall" ctaLabel="Bygg en beställning" />
|
||||
) : (
|
||||
<div className="grid grid-cols-1 gap-px border border-border bg-border md:grid-cols-3">
|
||||
{shown.map((d, i) => (
|
||||
<div key={d.id} className={`reveal-scale delay-${(i % 6) + 1} group flex flex-col bg-background p-6 transition-colors hover:bg-secondary/40`}>
|
||||
<p className="font-mono text-[10px] uppercase tracking-[0.12em] text-muted-foreground">{d.markets.join(" · ")}</p>
|
||||
<h3 className="mt-3 text-lg font-semibold tracking-[-0.01em]">{d.title}</h3>
|
||||
<div className="mt-4 flex items-center gap-2 font-mono text-[11px] text-muted-foreground">
|
||||
<span>{d.count > 0 ? new Intl.NumberFormat("sv-SE").format(d.count) + " poster" : "löpande"}</span>
|
||||
<span className="text-border">·</span>
|
||||
<span>{d.updated}</span>
|
||||
<CellProvenance level={level(d.confidence)} />
|
||||
</div>
|
||||
<div className="mt-6 flex items-center justify-between border-t border-border pt-4">
|
||||
<span className="font-mono text-sm tabular-nums">{formatSEK(Math.round(d.price_ore / 100))}</span>
|
||||
<div className="flex items-center gap-4">
|
||||
<Link href={`/katalog/${d.id}`} className="font-mono text-[11px] uppercase tracking-[0.08em] underline-offset-4 hover:underline">Visa →</Link>
|
||||
<Link href="/bestall" className="border border-foreground px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.08em] transition-colors hover:bg-foreground hover:text-background">Beställ</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Header } from "@/components/header";
|
||||
import { EmptyState, ErrorState, LoadingSkeleton } from "@/components/states";
|
||||
import { formatSEK } from "@/lib/data";
|
||||
|
||||
// Dashboard "Mina beställningar". Fetches GET /api/orders and renders the
|
||||
// customer's order ledger. Money arrives in öre; status follows the canonical
|
||||
// lifecycle (draft → … → in_production → review → accepted → delivered).
|
||||
|
||||
interface OrderRow {
|
||||
order_id: string;
|
||||
flow: string;
|
||||
status: string;
|
||||
total_ore: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// Swedish labels for the canonical lifecycle states.
|
||||
const STATUS_LABEL: Record<string, string> = {
|
||||
draft: "Utkast",
|
||||
quoted: "Offererad",
|
||||
deposit_pending: "Väntar förskott",
|
||||
in_production: "I produktion",
|
||||
review: "Granskas",
|
||||
revision: "Revidering",
|
||||
accepted: "Godkänd",
|
||||
delivered: "Levererad",
|
||||
};
|
||||
|
||||
const PRODUCTION_STATES = new Set(["in_production", "review", "revision"]);
|
||||
const DELIVERED_STATES = new Set(["accepted", "delivered"]);
|
||||
|
||||
function fmtDate(iso: string) {
|
||||
if (!iso) return "—";
|
||||
const d = new Date(iso);
|
||||
if (Number.isNaN(d.getTime())) return "—";
|
||||
return new Intl.DateTimeFormat("sv-SE", { year: "numeric", month: "2-digit", day: "2-digit" }).format(d);
|
||||
}
|
||||
|
||||
function shortId(id: string) {
|
||||
// Org-friendly truncation for long UUIDs; leave short ids untouched.
|
||||
return id.length > 12 ? `${id.slice(0, 8)}…` : id;
|
||||
}
|
||||
|
||||
export default function PortalPage() {
|
||||
const [orders, setOrders] = useState<OrderRow[] | null>(null);
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setError(false);
|
||||
setOrders(null);
|
||||
try {
|
||||
const res = await fetch("/api/orders", { cache: "no-store" });
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
const data = (await res.json()) as OrderRow[];
|
||||
setOrders(Array.isArray(data) ? data : []);
|
||||
} catch {
|
||||
setError(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
const total = orders?.length ?? 0;
|
||||
const inProduction = orders?.filter((o) => PRODUCTION_STATES.has(o.status)).length ?? 0;
|
||||
const delivered = orders?.filter((o) => DELIVERED_STATES.has(o.status)).length ?? 0;
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-background text-foreground">
|
||||
<Header />
|
||||
|
||||
<div className="mx-auto max-w-[80rem] px-6">
|
||||
{/* masthead — oversized numeral as graphic texture */}
|
||||
<header className="relative border-b border-border py-16 md:py-20">
|
||||
<span
|
||||
aria-hidden
|
||||
className="pointer-events-none absolute -top-6 right-0 select-none font-mono text-[clamp(7rem,18vw,15rem)] font-medium leading-none tracking-[-0.04em] text-foreground/[0.04]"
|
||||
>
|
||||
00
|
||||
</span>
|
||||
<p className="font-mono text-[11px] uppercase tracking-[0.18em] text-muted-foreground">
|
||||
Portal — Översikt
|
||||
</p>
|
||||
<h1 className="mt-5 max-w-[16ch] text-[clamp(2.6rem,7vw,5.5rem)] font-medium leading-[0.95] tracking-[-0.035em]">
|
||||
Mina beställningar.
|
||||
</h1>
|
||||
<p className="mt-5 font-mono text-sm text-muted-foreground">
|
||||
Allt på ett ställe.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<Content
|
||||
orders={orders}
|
||||
error={error}
|
||||
total={total}
|
||||
inProduction={inProduction}
|
||||
delivered={delivered}
|
||||
onRetry={load}
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function Content({
|
||||
orders,
|
||||
error,
|
||||
total,
|
||||
inProduction,
|
||||
delivered,
|
||||
onRetry,
|
||||
}: {
|
||||
orders: OrderRow[] | null;
|
||||
error: boolean;
|
||||
total: number;
|
||||
inProduction: number;
|
||||
delivered: number;
|
||||
onRetry: () => void;
|
||||
}) {
|
||||
if (error) {
|
||||
return (
|
||||
<div className="py-12">
|
||||
<ErrorState onRetry={onRetry} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (orders === null) {
|
||||
return (
|
||||
<div className="py-12">
|
||||
<LoadingSkeleton rows={6} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (orders.length === 0) {
|
||||
return (
|
||||
<div className="py-12">
|
||||
<EmptyState
|
||||
title="Inga beställningar än."
|
||||
line="Sätt ihop ett datajobb — marknader, fält, härkomst per fält. Betala hälften för att starta."
|
||||
ctaHref="/bestall"
|
||||
ctaLabel="Bygg din första beställning"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* stats row — shared hairline baseline, no fills */}
|
||||
<div className="grid grid-cols-1 gap-px border-b border-border bg-border sm:grid-cols-3">
|
||||
<Stat label="Antal" value={String(total)} />
|
||||
<Stat label="I produktion" value={String(inProduction)} />
|
||||
<Stat label="Levererade" value={String(delivered)} />
|
||||
</div>
|
||||
|
||||
{/* orders ledger */}
|
||||
<section className="border-b border-border py-12">
|
||||
<div className="mb-6 flex items-baseline justify-between">
|
||||
<h2 className="font-mono text-[11px] uppercase tracking-[0.14em] text-muted-foreground">
|
||||
Beställningar
|
||||
</h2>
|
||||
<span className="font-mono text-[11px] tabular-nums text-muted-foreground">
|
||||
{String(total).padStart(2, "0")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* desktop table */}
|
||||
<div className="hidden border border-border md:block">
|
||||
<div className="grid grid-cols-[1.4fr_1.6fr_1fr_1fr_0.9fr] items-center border-b border-border bg-background px-5 py-3 font-mono text-[10px] uppercase tracking-[0.14em] text-muted-foreground">
|
||||
<span>ID</span>
|
||||
<span>Flöde</span>
|
||||
<span>Status</span>
|
||||
<span className="text-right">Summa</span>
|
||||
<span className="text-right">Datum</span>
|
||||
</div>
|
||||
{orders.map((o) => (
|
||||
<Link
|
||||
key={o.order_id}
|
||||
href={`/order/${o.order_id}`}
|
||||
className="group grid grid-cols-[1.4fr_1.6fr_1fr_1fr_0.9fr] items-center border-b border-border px-5 py-4 transition-colors last:border-b-0 hover:bg-secondary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset"
|
||||
>
|
||||
<span className="font-mono text-[12px] tabular-nums tracking-tight">
|
||||
{shortId(o.order_id)}
|
||||
</span>
|
||||
<span className="truncate pr-4 text-[15px] tracking-[-0.01em]">{o.flow}</span>
|
||||
<span className="flex items-center gap-2 font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground">
|
||||
<StatusDot status={o.status} />
|
||||
{STATUS_LABEL[o.status] ?? o.status}
|
||||
</span>
|
||||
<span className="text-right font-mono text-[13px] tabular-nums">
|
||||
{formatSEK(o.total_ore / 100)}
|
||||
</span>
|
||||
<span className="flex items-center justify-end gap-3 text-right font-mono text-[12px] tabular-nums text-muted-foreground">
|
||||
{fmtDate(o.created_at)}
|
||||
<span aria-hidden className="text-foreground/30 transition-all duration-300 group-hover:translate-x-1 group-hover:text-foreground">
|
||||
→
|
||||
</span>
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* mobile stack */}
|
||||
<div className="flex flex-col border border-border md:hidden">
|
||||
{orders.map((o) => (
|
||||
<Link
|
||||
key={o.order_id}
|
||||
href={`/order/${o.order_id}`}
|
||||
className="flex flex-col gap-3 border-b border-border px-4 py-4 transition-colors last:border-b-0 hover:bg-secondary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset"
|
||||
>
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="font-mono text-[12px] tabular-nums tracking-tight">{shortId(o.order_id)}</span>
|
||||
<span className="font-mono text-[12px] tabular-nums">{formatSEK(o.total_ore / 100)}</span>
|
||||
</div>
|
||||
<span className="text-[15px] tracking-[-0.01em]">{o.flow}</span>
|
||||
<div className="flex items-center justify-between font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground">
|
||||
<span className="flex items-center gap-2">
|
||||
<StatusDot status={o.status} />
|
||||
{STATUS_LABEL[o.status] ?? o.status}
|
||||
</span>
|
||||
<span className="tabular-nums">{fmtDate(o.created_at)}</span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Stat({ label, value }: { label: string; value: string }) {
|
||||
return (
|
||||
<div className="bg-background px-6 py-8">
|
||||
<p className="font-mono text-[10.5px] uppercase tracking-[0.14em] text-muted-foreground">{label}</p>
|
||||
<p className="mt-3 text-[clamp(2.2rem,5vw,3rem)] font-medium leading-none tracking-[-0.03em] tabular-nums">
|
||||
{value}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Square provenance-coloured state marker — no red here (reserved for the EmptyState CTA). */
|
||||
function StatusDot({ status }: { status: string }) {
|
||||
const color = DELIVERED_STATES.has(status)
|
||||
? "var(--prov-3)"
|
||||
: PRODUCTION_STATES.has(status)
|
||||
? "var(--prov-2)"
|
||||
: "var(--muted-foreground)";
|
||||
return (
|
||||
<span aria-hidden className="inline-block h-2 w-2 shrink-0" style={{ backgroundColor: color }} />
|
||||
);
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import Link from "next/link";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const NAV = [
|
||||
{ label: "Katalog", href: "/#katalog" },
|
||||
{ label: "Katalog", href: "/katalog" },
|
||||
{ label: "Så funkar det", href: "/#motorn" },
|
||||
{ label: "Källor", href: "/#tackning" },
|
||||
{ label: "Källor", href: "/kallor" },
|
||||
{ label: "Priser", href: "/#priser" },
|
||||
];
|
||||
|
||||
@@ -65,7 +65,7 @@ export function Header() {
|
||||
|
||||
<div className="hidden items-center md:flex">
|
||||
<Link
|
||||
href="/bestall"
|
||||
href="/portal"
|
||||
className="px-4 py-2 font-mono text-[12px] uppercase tracking-[0.12em] text-muted-foreground transition-colors hover:text-foreground"
|
||||
>
|
||||
Logga in
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
"use client";
|
||||
|
||||
import { DataArtifact } from "@/components/data-artifact";
|
||||
|
||||
/**
|
||||
* Shared loading / empty / error states for the 0pt portal.
|
||||
* Mono, square, radius 0. One red accent per screen, used at most once
|
||||
* (the single EmptyState CTA). No fetching here — pure presentation.
|
||||
*
|
||||
* LoadingSkeleton: hairline rows with a slow left-to-right sweep (not pulsing
|
||||
* blobs). EmptyState: centered, generous air, faint DataArtifact "grid" motif.
|
||||
* ErrorState: terse interface voice + "Försök igen".
|
||||
*/
|
||||
|
||||
/** Hairline shimmer rows — a slow sweep travels left→right across each bar. */
|
||||
export function LoadingSkeleton({ rows = 5 }: { rows?: number }) {
|
||||
return (
|
||||
<div
|
||||
className="w-full border border-border bg-background"
|
||||
role="status"
|
||||
aria-busy="true"
|
||||
aria-label="Laddar"
|
||||
>
|
||||
<div className="flex items-center justify-between border-b border-border px-4 py-2.5">
|
||||
<span className="font-mono text-[10px] uppercase tracking-[0.18em] text-muted-foreground">
|
||||
laddar
|
||||
</span>
|
||||
<span className="font-mono text-[10px] uppercase tracking-[0.18em] text-border">
|
||||
·
|
||||
</span>
|
||||
</div>
|
||||
{Array.from({ length: Math.max(1, rows) }).map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="flex items-center gap-4 border-b border-border px-4 py-3.5 last:border-b-0"
|
||||
>
|
||||
<span className="opt-shimmer h-2.5 w-2.5 shrink-0" />
|
||||
<span
|
||||
className="opt-shimmer h-3"
|
||||
style={{ width: `${68 - (i % 3) * 14}%` }}
|
||||
/>
|
||||
<span className="opt-shimmer ml-auto h-3 w-16 shrink-0" />
|
||||
</div>
|
||||
))}
|
||||
<span className="sr-only">Laddar innehåll</span>
|
||||
|
||||
<style jsx>{`
|
||||
.opt-shimmer {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background-color: var(--secondary);
|
||||
}
|
||||
.opt-shimmer::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
transform: translateX(-100%);
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent 0%,
|
||||
color-mix(in srgb, var(--foreground) 9%, transparent) 50%,
|
||||
transparent 100%
|
||||
);
|
||||
animation: opt-sweep 2.1s ease-in-out infinite;
|
||||
}
|
||||
@keyframes opt-sweep {
|
||||
100% {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.opt-shimmer::after {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Nothing here yet — centered, lots of air, faint grid motif, one red CTA max. */
|
||||
export function EmptyState({
|
||||
title,
|
||||
line,
|
||||
ctaHref,
|
||||
ctaLabel,
|
||||
}: {
|
||||
title: string;
|
||||
line: string;
|
||||
ctaHref?: string;
|
||||
ctaLabel?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-center justify-center border border-border bg-background px-6 py-20 text-center sm:py-28">
|
||||
<div
|
||||
aria-hidden
|
||||
className="pointer-events-none relative mb-12 w-full max-w-xs opacity-40"
|
||||
>
|
||||
<DataArtifact variant="grid" />
|
||||
</div>
|
||||
|
||||
<p className="font-mono text-[10px] uppercase tracking-[0.22em] text-muted-foreground">
|
||||
tomt
|
||||
</p>
|
||||
<h2 className="mt-4 max-w-md text-balance text-3xl font-semibold leading-[1.04] tracking-tight sm:text-4xl">
|
||||
{title}
|
||||
</h2>
|
||||
<p className="mt-4 max-w-sm text-pretty text-[15px] leading-relaxed text-muted-foreground">
|
||||
{line}
|
||||
</p>
|
||||
|
||||
{ctaHref && ctaLabel ? (
|
||||
<a
|
||||
href={ctaHref}
|
||||
className="mt-9 inline-flex items-center gap-2 border px-5 py-2.5 font-mono text-[11px] uppercase tracking-[0.12em] text-background transition-opacity duration-200 hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
style={{
|
||||
backgroundColor: "var(--accent-red)",
|
||||
borderColor: "var(--accent-red)",
|
||||
}}
|
||||
>
|
||||
{ctaLabel}
|
||||
<span aria-hidden>→</span>
|
||||
</a>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Something broke — interface voice, single retry. */
|
||||
export function ErrorState({
|
||||
title = "Något gick fel",
|
||||
onRetry,
|
||||
}: {
|
||||
title?: string;
|
||||
onRetry?: () => void;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
role="alert"
|
||||
className="flex w-full flex-col items-center justify-center border border-border bg-background px-6 py-20 text-center sm:py-28"
|
||||
>
|
||||
<span
|
||||
aria-hidden
|
||||
className="mb-8 inline-block h-3 w-3"
|
||||
style={{ backgroundColor: "var(--accent-red)" }}
|
||||
/>
|
||||
|
||||
<p className="font-mono text-[10px] uppercase tracking-[0.22em] text-muted-foreground">
|
||||
fel
|
||||
</p>
|
||||
<h2 className="mt-4 max-w-md text-balance text-3xl font-semibold leading-[1.04] tracking-tight sm:text-4xl">
|
||||
{title}
|
||||
</h2>
|
||||
<p className="mt-4 max-w-sm text-pretty text-[15px] leading-relaxed text-muted-foreground">
|
||||
Kunde inte hämta data. Ingen ändring sparad.
|
||||
</p>
|
||||
|
||||
{onRetry ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onRetry}
|
||||
className="mt-9 inline-flex items-center gap-2 border border-foreground bg-background px-5 py-2.5 font-mono text-[11px] uppercase tracking-[0.12em] text-foreground transition-colors duration-200 hover:bg-foreground hover:text-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
Försök igen
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user