feat: admin Verktyg (live fordon + sanktioner lookup) + service-type pricing in configurator
/admin/verktyg uses live /api/vehicles (RDW) + /api/screen (OpenSanctions); added to admin nav. Configurator now has a Tjänst selector that applies each service's price multiplier (lib/services) to the live estimate + summary; service_type carried into the order so orders-store prices by service. tsc 0, build green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
+19
-3
@@ -5,6 +5,7 @@ import { useMemo, useState, useEffect } from "react";
|
||||
import { OrderStepper } from "@/components/order-stepper";
|
||||
import { ProvenanceBadge } from "@/components/provenance-badge";
|
||||
import { createOrder } from "@/lib/order-client";
|
||||
import { SERVICES, serviceById } from "@/lib/services";
|
||||
import {
|
||||
MARKETS,
|
||||
ENTITY_TYPES,
|
||||
@@ -34,10 +35,11 @@ export default function ConfiguratorPage() {
|
||||
const [frequency, setFrequency] = useState<Frequency>("Engångs");
|
||||
const [confidence, setConfidence] = useState(92);
|
||||
const [formats, setFormats] = useState<string[]>(["CSV", "Tabellvy (NocoDB)"]);
|
||||
const [service, setService] = useState("data");
|
||||
|
||||
const est = useMemo(
|
||||
() => computeEstimate({ markets, type, fieldIds, enrichmentIds, volume, frequency, confidence }),
|
||||
[markets, type, fieldIds, enrichmentIds, volume, frequency, confidence],
|
||||
() => computeEstimate({ markets, type, fieldIds, enrichmentIds, volume, frequency, confidence, serviceMult: serviceById(service)?.mult ?? 1 }),
|
||||
[markets, type, fieldIds, enrichmentIds, volume, frequency, confidence, service],
|
||||
);
|
||||
|
||||
// Persist so the deposit screen shows the same numbers.
|
||||
@@ -55,7 +57,7 @@ export default function ConfiguratorPage() {
|
||||
async function submit() {
|
||||
if (creating) return;
|
||||
setCreating(true);
|
||||
const config = { markets, type, fieldIds, enrichmentIds, volume, frequency, confidence, formats };
|
||||
const config = { markets, type, fieldIds, enrichmentIds, volume, frequency, confidence, formats, service_type: service };
|
||||
const id = await createOrder(frequency === "Engångs" ? "custom" : "subscription", config);
|
||||
router.push(id ? `/bestall/forskott?order=${encodeURIComponent(id)}` : "/bestall/forskott");
|
||||
}
|
||||
@@ -129,6 +131,19 @@ export default function ConfiguratorPage() {
|
||||
<div className="mt-12 grid grid-cols-1 gap-6 lg:grid-cols-[1fr_360px]">
|
||||
{/* LEFT — builder */}
|
||||
<div className="reveal-left flex flex-col gap-4">
|
||||
<Block index="00" label="Tjänst">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{SERVICES.map((s) => (
|
||||
<Chip key={s.id} active={service === s.id} onClick={() => setService(s.id)}>
|
||||
{s.name}
|
||||
</Chip>
|
||||
))}
|
||||
</div>
|
||||
{serviceById(service) ? (
|
||||
<p className="mt-3 text-xs text-muted-foreground">{serviceById(service)!.covers}</p>
|
||||
) : null}
|
||||
</Block>
|
||||
|
||||
<Block index="01" label="Marknader">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{MARKETS.map((m) => (
|
||||
@@ -280,6 +295,7 @@ export default function ConfiguratorPage() {
|
||||
</div>
|
||||
<dl className="divide-y divide-border">
|
||||
{[
|
||||
["Tjänst", serviceById(service)?.name ?? service],
|
||||
["Marknader", markets.join(" · ") || "—"],
|
||||
["Typ", type],
|
||||
["Fält", String(FIELDS.filter((f) => f.locked || fieldIds.includes(f.id)).length)],
|
||||
|
||||
Reference in New Issue
Block a user