feat: full service catalog + custom-job intake (describe -> AI-assist -> order)
lib/services (11 categories: data, scraping, mapping, normalization, consolidation->CRM/ERP, documents/OCR, enrichment, ICP, ML, BI, feeds across the 3 flows); /tjanster catalog; /bestall/beskriv NL intake; /api/ai/parse (engine LLM or heuristic NL->config); CRM/ERP destinations; Tjänster in nav. Sells every custom data service through the platform. tsc 0, build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { engineFetch } from "@/lib/engine";
|
||||
|
||||
// POST /api/ai/parse (docs/04) — natural-language need -> prefilled order config.
|
||||
// Uses the engine's LLM when available; otherwise a transparent keyword heuristic.
|
||||
const MARKETS: [RegExp, string][] = [
|
||||
[/sverige|svensk|\bse\b/i, "SE"], [/norge|norsk|\bno\b/i, "NO"], [/danmark|dansk|\bdk\b/i, "DK"],
|
||||
[/finland|finsk|\bfi\b/i, "FI"], [/tyskland|\bde\b/i, "DE"], [/storbritannien|\buk\b|\bgb\b/i, "GB"],
|
||||
];
|
||||
const SERVICE: [RegExp, string][] = [
|
||||
[/skrap|scrap/i, "scraping"], [/mappa|matcha|match|koppla/i, "mapping"],
|
||||
[/normaliser|städ|dedup|tvätta/i, "normalization"], [/konsolider|crm|erp|hubspot|salesforce|dynamics|pipedrive|fivecrm/i, "consolidation"],
|
||||
[/dokument|ocr|pdf|scann/i, "documents"], [/berik|enrich/i, "enrichment"],
|
||||
[/\bicp\b|leads?|målgrupp|beslutsfattare/i, "icp"], [/\bml\b|modell|scoring|prognos|kluster/i, "ml"],
|
||||
[/\bbi\b|dashboard|analys|marknadsanalys/i, "bi"], [/flöde|feed|övervak|freshness/i, "feeds"],
|
||||
];
|
||||
const FIELDS: [RegExp, string][] = [
|
||||
[/e-?post|email|mejl|kontakt|telefon/i, "contact"], [/omsättning|finans|bokslut|resultat|nyckeltal/i, "financials"],
|
||||
[/lei|cross-?border/i, "lei"], [/huvudman|ubo|ägar/i, "ubo"], [/intent|köpsignal|signal/i, "intent"],
|
||||
];
|
||||
const DEST: [RegExp, string][] = [
|
||||
[/hubspot/i, "HubSpot"], [/salesforce/i, "Salesforce"], [/dynamics/i, "Microsoft Dynamics"],
|
||||
[/pipedrive/i, "Pipedrive"], [/fivecrm/i, "FiveCRM"], [/sheets/i, "Google Sheets"],
|
||||
];
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const { text } = await req.json().catch(() => ({ text: "" }));
|
||||
if (!text) return NextResponse.json({ error: { code: "bad_request", message: "text krävs" } }, { status: 400 });
|
||||
|
||||
const eng = await engineFetch("/ai/parse", { method: "POST", body: JSON.stringify({ text }) });
|
||||
if (eng && eng.ok) return NextResponse.json(await eng.json());
|
||||
|
||||
const pick = (table: [RegExp, string][]) => table.filter(([re]) => re.test(text)).map(([, v]) => v);
|
||||
const markets = [...new Set(pick(MARKETS))];
|
||||
const service = pick(SERVICE)[0] ?? "data";
|
||||
const fields = [...new Set(pick(FIELDS))];
|
||||
const destination = pick(DEST)[0] ?? null;
|
||||
const volMatch = text.replace(/\s/g, "").match(/(\d{3,})/);
|
||||
const volume = volMatch ? Math.min(1_000_000, parseInt(volMatch[1], 10)) : 5000;
|
||||
|
||||
return NextResponse.json({
|
||||
config: {
|
||||
service_type: service,
|
||||
markets: markets.length ? markets : ["SE"],
|
||||
type: "Bolag",
|
||||
fieldIds: fields.length ? fields : ["lei"],
|
||||
enrichmentIds: [],
|
||||
volume,
|
||||
frequency: service === "feeds" || service === "enrichment" ? "Veckovis" : "Engångs",
|
||||
confidence: 92,
|
||||
destination,
|
||||
description: text,
|
||||
},
|
||||
rationale: `Tolkat som ${service}${markets.length ? ` · ${markets.join(", ")}` : ""}${destination ? ` · ${destination}` : ""}. Justera fritt.`,
|
||||
heuristic: true,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Header } from "@/components/header";
|
||||
import { OrderStepper } from "@/components/order-stepper";
|
||||
import { SERVICES, DESTINATIONS_CRM, serviceById } from "@/lib/services";
|
||||
|
||||
const PLACEHOLDER =
|
||||
"T.ex. \"Konsolidera vår admindata och pusha alla svenska kunder med omsättning och beslutsfattare till HubSpot\" eller \"Skrapa alla norska bolag inom bygg med e-post\".";
|
||||
|
||||
export default function DescribePage() {
|
||||
const router = useRouter();
|
||||
const [service, setService] = useState("data");
|
||||
const [text, setText] = useState("");
|
||||
const [destination, setDestination] = useState<string>("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [rationale, setRationale] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
const s = new URLSearchParams(window.location.search).get("service");
|
||||
if (s && serviceById(s)) setService(s);
|
||||
}, []);
|
||||
|
||||
const svc = serviceById(service);
|
||||
const showDest = service === "consolidation" || service === "enrichment" || service === "icp";
|
||||
|
||||
async function submit() {
|
||||
if (busy || !text.trim()) return;
|
||||
setBusy(true);
|
||||
setRationale("");
|
||||
let config: Record<string, unknown> = { service_type: service, description: text, destination: destination || null };
|
||||
try {
|
||||
const ai = await fetch("/api/ai/parse", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: `${svc?.name ?? ""}. ${text}` }) });
|
||||
if (ai.ok) {
|
||||
const d = await ai.json();
|
||||
config = { ...d.config, service_type: service, description: text, destination: destination || d.config?.destination || null };
|
||||
setRationale(d.rationale ?? "");
|
||||
}
|
||||
} catch {}
|
||||
try {
|
||||
const flow = svc?.flow === "subscription" ? "subscription" : "custom";
|
||||
const res = await fetch("/api/orders", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ flow, config }) });
|
||||
const o = await res.json();
|
||||
if (o?.order_id) { router.push(`/bestall/forskott?order=${encodeURIComponent(o.order_id)}`); return; }
|
||||
} catch {}
|
||||
setBusy(false);
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-background text-foreground">
|
||||
<Header />
|
||||
<OrderStepper active={1} />
|
||||
<div className="mx-auto max-w-[60rem] px-6 py-16">
|
||||
<p className="font-mono text-[11px] uppercase tracking-[0.16em] text-muted-foreground">Skräddarsytt — Beskriv</p>
|
||||
<h1 className="mt-4 max-w-[16ch] text-5xl font-medium leading-[0.95] tracking-[-0.035em] md:text-7xl">Beskriv behovet.</h1>
|
||||
<p className="mt-5 max-w-[48ch] font-mono text-[12px] uppercase tracking-[0.06em] text-muted-foreground">
|
||||
Säg det på svenska. Vi tolkar, prissätter, scopar — du godkänner.
|
||||
</p>
|
||||
|
||||
<div className="mt-10">
|
||||
<p className="font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground">Tjänst</p>
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
{SERVICES.map((s) => (
|
||||
<button
|
||||
key={s.id}
|
||||
onClick={() => setService(s.id)}
|
||||
className="border px-3 py-2 font-mono text-[11px] uppercase tracking-[0.08em] transition-colors"
|
||||
style={{
|
||||
borderColor: service === s.id ? "var(--foreground)" : "var(--border)",
|
||||
backgroundColor: service === s.id ? "var(--foreground)" : "transparent",
|
||||
color: service === s.id ? "var(--background)" : "var(--foreground)",
|
||||
}}
|
||||
>
|
||||
{s.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{svc ? <p className="mt-3 text-sm text-muted-foreground">{svc.covers} <span className="text-muted-foreground/60">→ {svc.deliverable}</span></p> : null}
|
||||
</div>
|
||||
|
||||
<div className="mt-8">
|
||||
<p className="font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground">Ditt behov</p>
|
||||
<textarea
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
placeholder={PLACEHOLDER}
|
||||
rows={5}
|
||||
className="mt-3 w-full resize-none border border-border bg-input px-4 py-3 text-sm outline-none focus:border-foreground"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{showDest ? (
|
||||
<div className="mt-6">
|
||||
<p className="font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground">Leverera till (CRM/ERP)</p>
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
{DESTINATIONS_CRM.map((d) => (
|
||||
<button
|
||||
key={d}
|
||||
onClick={() => setDestination(destination === d ? "" : d)}
|
||||
className="border px-3 py-2 font-mono text-[11px] uppercase tracking-[0.08em] transition-colors"
|
||||
style={{
|
||||
borderColor: destination === d ? "var(--accent-red)" : "var(--border)",
|
||||
backgroundColor: destination === d ? "rgba(228,0,20,0.06)" : "transparent",
|
||||
}}
|
||||
>
|
||||
{d}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{rationale ? <p className="mt-6 font-mono text-[11px] text-muted-foreground">{rationale}</p> : null}
|
||||
|
||||
<div className="mt-10 flex flex-wrap items-center gap-4">
|
||||
<button
|
||||
onClick={submit}
|
||||
disabled={busy || !text.trim()}
|
||||
className="bg-foreground px-6 py-3.5 font-mono text-[12px] uppercase tracking-[0.1em] text-background transition-colors hover:bg-[var(--accent-red)] disabled:opacity-50"
|
||||
>
|
||||
{busy ? "Tolkar…" : "Få estimat →"}
|
||||
</button>
|
||||
<Link href="/bestall" className="font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground underline-offset-4 hover:text-foreground hover:underline">
|
||||
Eller bygg detaljerat
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useReveal } from "@/hooks/use-reveal";
|
||||
import { SERVICES, FLOW_LABEL, type Flow } from "@/lib/services";
|
||||
import { Header } from "@/components/header";
|
||||
|
||||
const ORDER: Flow[] = ["custom", "catalog", "subscription"];
|
||||
|
||||
function ctaFor(flow: Flow, id: string): { href: string; label: string } {
|
||||
if (flow === "catalog") return { href: "/katalog", label: "Bläddra katalog" };
|
||||
if (flow === "subscription") return { href: `/bestall/beskriv?service=${id}`, label: "Konfigurera flöde" };
|
||||
return { href: `/bestall/beskriv?service=${id}`, label: "Beskriv behovet" };
|
||||
}
|
||||
|
||||
export default function ServicesPage() {
|
||||
const ref = useReveal<HTMLDivElement>();
|
||||
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-10">
|
||||
<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]">
|
||||
∑
|
||||
</span>
|
||||
<p className="reveal font-mono text-[11px] uppercase tracking-[0.18em] text-muted-foreground">Tjänster</p>
|
||||
<h1 className="reveal delay-1 mt-5 max-w-[20ch] text-[clamp(2.6rem,7vw,5.5rem)] font-medium leading-[0.95] tracking-[-0.035em]">
|
||||
All data. På beställning.
|
||||
</h1>
|
||||
<p className="reveal delay-2 mt-5 max-w-[52ch] font-mono text-[12px] uppercase tracking-[0.06em] text-muted-foreground">
|
||||
Skrapning. Mappning. Normalisering. Konsolidering till CRM/ERP. ML. BI. Allt med härkomst per fält.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{ORDER.map((flow) => {
|
||||
const items = SERVICES.filter((s) => s.flow === flow);
|
||||
return (
|
||||
<section key={flow} className="mt-16">
|
||||
<div className="flex items-baseline justify-between border-b border-border pb-4">
|
||||
<h2 className="font-mono text-[11px] uppercase tracking-[0.16em] text-muted-foreground">{FLOW_LABEL[flow]}</h2>
|
||||
<span className="font-mono text-[11px] tabular-nums text-muted-foreground/60">{String(items.length).padStart(2, "0")}</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-px border border-border bg-border md:grid-cols-2 lg:grid-cols-3">
|
||||
{items.map((s, i) => {
|
||||
const cta = ctaFor(flow, s.id);
|
||||
return (
|
||||
<div key={s.id} className={`reveal delay-${(i % 6) + 1} group flex flex-col bg-background p-6 transition-colors hover:bg-secondary/40`}>
|
||||
<h3 className="text-lg font-semibold tracking-[-0.01em]">{s.name}</h3>
|
||||
<p className="mt-1 font-mono text-[11px] uppercase tracking-[0.06em] text-muted-foreground">{s.tagline}</p>
|
||||
<p className="mt-4 flex-1 text-sm text-muted-foreground">{s.covers}</p>
|
||||
<p className="mt-4 font-mono text-[10.5px] uppercase tracking-[0.08em] text-muted-foreground/70">→ {s.deliverable}</p>
|
||||
<Link href={cta.href} className="mt-5 inline-flex items-center gap-2 font-mono text-[11px] uppercase tracking-[0.1em] underline-offset-4 hover:underline">
|
||||
{cta.label}
|
||||
<span aria-hidden className="transition-transform duration-300 group-hover:translate-x-1">→</span>
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
|
||||
<div className="mt-16 flex flex-wrap items-center gap-4 border-t border-border pt-10">
|
||||
<p className="text-lg font-medium tracking-[-0.01em]">Vet du inte vad du behöver?</p>
|
||||
<Link href="/bestall/beskriv" className="bg-foreground px-6 py-3.5 font-mono text-[12px] uppercase tracking-[0.1em] text-background transition-colors hover:bg-[var(--accent-red)]">
|
||||
Beskriv behovet →
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import Link from "next/link";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const NAV = [
|
||||
{ label: "Tjänster", href: "/tjanster" },
|
||||
{ label: "Katalog", href: "/katalog" },
|
||||
{ label: "Så funkar det", href: "/#motorn" },
|
||||
{ label: "Källor", href: "/kallor" },
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// The 0pt service catalog. Every sellable service maps to one of the three flows
|
||||
// (docs/01): catalog product, custom job, subscription. Categories are tags within
|
||||
// those flows — not separate machinery.
|
||||
|
||||
export type Flow = "catalog" | "custom" | "subscription";
|
||||
|
||||
export interface Service {
|
||||
id: string;
|
||||
name: string;
|
||||
tagline: string; // terse, confident
|
||||
covers: string; // one line of scope
|
||||
flow: Flow;
|
||||
deliverable: string;
|
||||
mult: number; // price multiplier vs a base dataset job
|
||||
}
|
||||
|
||||
export const SERVICES: Service[] = [
|
||||
{ id: "data", name: "Dataleverans", tagline: "Färdig eller skräddarsydd.", covers: "Bolag, beslutsfattare, fordon, finansiellt — per fält med härkomst.", flow: "custom", deliverable: "CSV · Parquet · JSON · API", mult: 1.0 },
|
||||
{ id: "scraping", name: "Webbskrapning", tagline: "Lagligt insamlat.", covers: "Officiella API:er och tydligt publika sidor. Aldrig bakom inloggning.", flow: "custom", deliverable: "Strukturerat dataset + källa per fält", mult: 1.1 },
|
||||
{ id: "mapping", name: "Mappning & matchning", tagline: "Era data mot världen.", covers: "Koppla era poster mot orgnr/LEI och externa nycklar. Cross-border.", flow: "custom", deliverable: "Matchad fil + matchningskonfidens", mult: 1.2 },
|
||||
{ id: "normalization", name: "Normalisering", tagline: "Städat. Standardiserat.", covers: "Format, dubbletter, validering (e-post/telefon), enhetlig taxonomi.", flow: "custom", deliverable: "Ren datamodell + kvalitetsrapport", mult: 1.1 },
|
||||
{ id: "consolidation", name: "Konsolidering → CRM/ERP", tagline: "En sanning. Rätt system.", covers: "Slå ihop admindata och pusha till HubSpot, Salesforce, Dynamics, Pipedrive, FiveCRM.", flow: "custom", deliverable: "Konsoliderad data + push/sync", mult: 1.4 },
|
||||
{ id: "documents", name: "Dokument & OCR", tagline: "Pixlar till poster.", covers: "PDF, bilder, scannade myndighetsdokument → strukturerade fält.", flow: "custom", deliverable: "Strukturerat dataset från dokument", mult: 1.3 },
|
||||
{ id: "enrichment", name: "Berikning", tagline: "Fyll luckorna.", covers: "Kontakter, firmografik, finansiellt, köpsignaler — med laglig grund.", flow: "subscription", deliverable: "Berikad fil eller löpande flöde", mult: 1.2 },
|
||||
{ id: "icp", name: "ICP & leads", tagline: "Rätt målgrupp.", covers: "Målgruppslistor med beslutsfattare, härkomst per kontakt.", flow: "catalog", deliverable: "Lead-lista + export till CRM", mult: 1.2 },
|
||||
{ id: "ml", name: "ML-jobb", tagline: "Modeller på er data.", covers: "Scoring, matchning, prognos, klustring — tränat på era + våra data.", flow: "custom", deliverable: "Modell + prediktioner + API", mult: 1.8 },
|
||||
{ id: "bi", name: "BI & marknadsanalys", tagline: "Beslut, inte bara siffror.", covers: "Dashboards, marknadsöversikter, konkurrent- och täckningsanalys.", flow: "custom", deliverable: "Metabase-dashboard + rapport", mult: 1.5 },
|
||||
{ id: "feeds", name: "Flöden & övervakning", tagline: "Alltid färskt.", covers: "Återkommande leverans, freshness-bevakning, webhook vid förändring.", flow: "subscription", deliverable: "Webhook/feed + larm", mult: 1.3 },
|
||||
];
|
||||
|
||||
export const FLOW_LABEL: Record<Flow, string> = {
|
||||
catalog: "Katalog",
|
||||
custom: "Skräddarsytt",
|
||||
subscription: "Flöde",
|
||||
};
|
||||
|
||||
// CRM/ERP destinations for the consolidation/push services.
|
||||
export const DESTINATIONS_CRM = ["HubSpot", "Salesforce", "Microsoft Dynamics", "Pipedrive", "FiveCRM", "Google Sheets", "CSV / API"];
|
||||
|
||||
export function serviceById(id: string): Service | undefined {
|
||||
return SERVICES.find((s) => s.id === id);
|
||||
}
|
||||
Reference in New Issue
Block a user