app / frontend /src /components /views /Overview.jsx
Aissugur Kurganbekov
Tamga — evidence-backed customs document audit
373030b
Raw History Blame Contribute Delete
11 kB
import { useEffect, useState } from "react";
import { api } from "../../api";
import {
IconCheck,
IconDoc,
IconEval,
IconQuote,
IconShield,
IconSpark,
} from "../../lib/icons";
import { useScrollReveal } from "../../lib/useScrollReveal";
import Button from "../ui/Button";
import Card from "../ui/Card";
import { EmptyState, ErrorState, LoadingState, SuccessNote } from "../ui/States";
import DocumentCard from "../DocumentCard";
import Upload from "../Upload";
import HeroPreview from "./HeroPreview";
const STEPS = [
{ t: "Send the packet", d: "Drop the invoice, packing list, contract, transport docs and certificate of origin. Scans and photos work too." },
{ t: "Cross-check", d: "Tamga reads every document and matches the fields and EAEU rules against each other." },
{ t: "Cite", d: "Every discrepancy points to the exact line in the exact document. Nothing is filed or signed without you." },
];
// Lightweight count-up for the stats band (rAF, ease-out cubic).
function CountUp({ end, suffix = "", duration = 1200 }) {
const [v, setV] = useState(0);
useEffect(() => {
if (!end) return;
let raf, start;
const tick = (t) => {
if (!start) start = t;
const p = Math.min((t - start) / duration, 1);
setV(Math.round((1 - Math.pow(1 - p, 3)) * end));
if (p < 1) raf = requestAnimationFrame(tick);
};
raf = requestAnimationFrame(tick);
return () => cancelAnimationFrame(raf);
}, [end, duration]);
return (
<>
{v}
{suffix}
</>
);
}
export default function Overview({ documents, loading, reload, onTryDemo, seeding, onOpenEval }) {
const [uploading, setUploading] = useState(false);
const [message, setMessage] = useState("");
const [error, setError] = useState("");
useScrollReveal([loading, documents.length]);
async function onFile(file) {
setError("");
setMessage("");
setUploading(true);
try {
const doc = await api.uploadDocument(file);
await reload();
if (doc.status === "processed") {
setMessage(`Uploaded "${doc.filename}" — ${doc.num_chunks} chunks ready.`);
} else {
setError(`"${doc.filename}" couldn't be processed: ${doc.error || "unknown error"}`);
}
} catch (err) {
setError(err.message);
} finally {
setUploading(false);
}
}
async function onDelete(doc) {
setError("");
setMessage("");
try {
await api.deleteDocument(doc.id);
await reload();
setMessage(`Deleted "${doc.filename}".`);
} catch (err) {
setError(err.message);
}
}
function scrollToUpload() {
document
.getElementById("upload-zone")
?.scrollIntoView({ behavior: "smooth", block: "center" });
}
return (
<div className="landing">
{/* ---- Hero ---- */}
<section className="hero-stage">
<div>
<h1 className="hero-h1">
Answers you can <span className="clip">prove.</span>
</h1>
<p className="hero-sub">
Tamga audits a customs declaration packet (invoice, packing list,
contract, transport docs and certificate of origin) for HS codes,
value, origin, weights and the mismatches that stall clearance. Every
finding cites the exact document, and when the evidence isn't there it
says so instead of guessing.
</p>
<div className="hero-cta">
<Button variant="primary" size="lg" loading={seeding} onClick={onTryDemo}>
{seeding ? "Loading demo…" : "Try the live demo"}
</Button>
<Button variant="ghost" size="lg" onClick={scrollToUpload}>
Upload a document
</Button>
</div>
<div className="hero-trust-strip">
<span>Cites every finding</span>
<span>Reads scans (OCR)</span>
<span>You stay the declarant</span>
</div>
</div>
<HeroPreview />
</section>
{/* ---- Works-with strip ---- */}
<div className="logo-strip">
<span className="ls-label">Reads your</span>
<span className="ls-item"><IconDoc size={16} /> Commercial invoices</span>
<span className="ls-item"><IconDoc size={16} /> Packing lists</span>
<span className="ls-item"><IconDoc size={16} /> Declarations</span>
<span className="ls-item"><IconDoc size={16} /> Certificates of origin</span>
<span className="ls-item"><IconDoc size={16} /> PDF &amp; TXT</span>
</div>
{/* ---- Upload + documents (functional) ---- */}
<section id="upload-zone" className="reveal">
<p className="eyebrow-mono">01 / <b>Try it with your own files</b></p>
<div className="section-title">
<h2>Add a document</h2>
<span className="muted">PDF or TXT · 10 MB max</span>
</div>
<Upload onFile={onFile} uploading={uploading} />
{message && <div style={{ marginTop: 16 }}><SuccessNote>{message}</SuccessNote></div>}
<div style={{ marginTop: 12 }}><ErrorState>{error}</ErrorState></div>
<div style={{ marginTop: 28 }}>
<div className="section-title">
<h2>Your documents</h2>
{documents.length > 0 && <span className="muted">{documents.length} total</span>}
</div>
{loading ? (
<Card>
<LoadingState lines={3} label="Loading documents…" />
</Card>
) : documents.length === 0 ? (
<EmptyState title="No documents yet">
Click <strong>Try the live demo</strong> to load a sample customs
packet, or drop your own file above.
</EmptyState>
) : (
<div className="doc-grid">
{documents.map((d) => (
<DocumentCard key={d.id} doc={d} onDelete={onDelete} />
))}
</div>
)}
</div>
</section>
{/* ---- How it works ---- */}
<section className="reveal">
<p className="eyebrow-mono">02 / <b>How it works</b></p>
<div className="flow">
{STEPS.map(({ t, d }, i) => (
<div key={t} className="flow-step">
<div className="flow-num">{i + 1}</div>
<h3>{t}</h3>
<p>{d}</p>
</div>
))}
</div>
</section>
{/* ---- Stats band ---- */}
<section className="reveal">
<div className="stats-band">
<div className="stat">
<div className="stat-num"><CountUp end={100} suffix="%" /></div>
<div className="stat-label">of findings cite the exact document</div>
</div>
<div className="stat">
<div className="stat-num">0</div>
<div className="stat-label">claims without a source</div>
</div>
<div className="stat">
<div className="stat-num"><CountUp end={48} />h</div>
<div className="stat-label">free pilot turnaround</div>
</div>
</div>
</section>
{/* ---- Why it's trustworthy (bento) ---- */}
<section className="reveal">
<p className="eyebrow-mono">03 / <b>Why it's trustworthy</b></p>
<div className="bento">
<div className="bento-tile bento-cite">
<IconQuote size={20} />
<h3>Citation-first findings</h3>
<p>Every flag shows the exact document, line and relevance, so a broker verifies it in one glance.</p>
<div className="bento-rankviz">
<div className="bento-rankbar" style={{ width: "100%" }} />
<div className="bento-rankbar" style={{ width: "72%" }} />
<div className="bento-rankbar" style={{ width: "48%" }} />
</div>
</div>
<div className="bento-tile bento-abst">
<IconShield size={20} />
<h3>Flags the gap when unsure</h3>
<p>If a field is missing or the evidence is weak, Tamga flags it instead of guessing.</p>
</div>
<div className="bento-tile bento-src">
<IconSpark size={20} />
<h3>Source-only</h3>
<p>Extractive by default. It can't invent a value that isn't in the packet.</p>
</div>
<div className="bento-tile bento-eval">
<IconEval size={20} />
<h3>Graded every run</h3>
<p>A golden dataset grades grounding on every run — open the evaluation to see the current numbers.</p>
</div>
</div>
</section>
{/* ---- Evaluation teaser ---- */}
<section className="reveal">
<div className="eval-teaser">
<div>
<h2>We grade ourselves.</h2>
<p>
Most AI demos ask you to trust them. Tamga ships a golden-dataset
evaluation that scores whether it stayed grounded, and counts a
correct abstention as a success.
</p>
<Button variant="ghost" onClick={onOpenEval}>
Open the evaluation
</Button>
</div>
<div className="metric-grid" style={{ margin: 0, minWidth: 240 }}>
<div className="metric-card">
<div className="metric-value good">100%</div>
<div className="metric-label">Citation coverage target</div>
</div>
<div className="metric-card">
<div className="metric-value good">0</div>
<div className="metric-label">Unsupported findings target</div>
</div>
</div>
</div>
</section>
{/* ---- Proof band (dark) ---- */}
<section className="proof-band">
<div className="pb-head">
<h2>Trust you can check.</h2>
<p className="pb-sub">
Tamga doesn't ask you to trust it, it shows its work. Every finding
links back to the exact source line, it flags the gap when the packet
doesn't say, and a bundled evaluation grades that grounding on every
run.
</p>
</div>
<div className="pb-proof">
<div className="pb-proof-item">
<IconCheck size={20} />
<div>
<b>100%</b>
<span className="pb-proof-label">of findings carry a citation</span>
</div>
</div>
<div className="pb-proof-item">
<IconCheck size={20} />
<div>
<b>0</b>
<span className="pb-proof-label">findings without evidence</span>
</div>
</div>
<div className="pb-proof-item">
<IconCheck size={20} />
<div>
<b>OCR</b>
<span className="pb-proof-label">reads scanned &amp; photographed packets</span>
</div>
</div>
</div>
</section>
</div>
);
}