Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/demo/[institution]/tx/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function TransactionDetailPage() {

{txn.explanation && (
<Card>
<CardHeader title="Why Fable stepped in" />
<CardHeader title={flagged ? "Why Fable stepped in" : "Why it went through"} />
<p className="text-[14px] leading-relaxed text-d-muted">{txn.explanation}</p>
</Card>
)}
Expand Down
17 changes: 13 additions & 4 deletions src/components/demo/SignalCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"use client";

import { useEffect, useState } from "react";
import { WarningCircle } from "@phosphor-icons/react";
import { CheckCircle, WarningCircle } from "@phosphor-icons/react";
import type { Signal } from "@/lib/fable/types";

/** Signals that lower the score rather than raise it. */
const IN_FAVOUR = new Set(["tenure"]);

/**
* One detected Shield signal. Enters with a staggered slide-up, starting after
* the risk score has settled.
Expand All @@ -22,9 +25,15 @@ export function SignalCard({ signal, index }: { signal: Signal; index: number })
shown ? "translate-y-0 opacity-100" : "translate-y-3 opacity-0"
}`}
>
<span className="flex size-8 shrink-0 items-center justify-center rounded-full bg-amber-500/14 text-amber-500">
<WarningCircle size={18} weight="fill" />
</span>
{IN_FAVOUR.has(signal.code) ? (
<span className="flex size-8 shrink-0 items-center justify-center rounded-full bg-emerald-500/14 text-emerald-500">
<CheckCircle size={18} weight="fill" />
</span>
) : (
<span className="flex size-8 shrink-0 items-center justify-center rounded-full bg-amber-500/14 text-amber-500">
<WarningCircle size={18} weight="fill" />
</span>
)}
<div className="min-w-0">
<p className="text-[13px] font-semibold text-d-text">{signal.label}</p>
<p className="mt-0.5 text-[12px] leading-relaxed text-d-muted">{signal.detail}</p>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/fable/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const SIGNAL_LABELS: Record<string, string> = {
behavioral_anomaly: "Behavioral anomaly",
timezone_mismatch: "Timezone mismatch",
system_error: "System notice",
tenure: "Long clean history",
};
const SIGNAL_WEIGHTS: Record<string, number> = {
amount_anomaly: 0.25,
Expand Down Expand Up @@ -207,7 +208,7 @@ export function parseApiSignals(raw: string[]): Signal[] {
return {
code,
label: code === "nip_code" ? "NIP risk code" : (SIGNAL_LABELS[code] ?? rawCode.replace(/_/g, " ")),
detail: detail.replace(/\s*\(\+[0-9.]+\)/, "") || "Signal detected",
detail: detail.replace(/\s*\([+-][0-9.]+\)/, "") || "Signal detected",
weight: weightMatch ? Number(weightMatch[1]) : (SIGNAL_WEIGHTS[code] ?? 0.1),
};
});
Expand Down
Loading