Skip to Content
BBRICKSv0.7.4
PR PortalFraud review

FraudSignalPill

A fraud signal as a pill: its words from the provider's statusTables.prFraud, else FRAUD_SIGNALS; its colour from the severity (high red, medium amber, low grey) when given, else the signal's own tone. The severity is also in the accessible name and the tooltip, so the colour is never the only cue. An unknown kind shows as itself.

import { FraudSignalPill } from '@ergasti/bricks';

Examples

Fraud review

A queue of cases (each with its signals as pills), the selected case's evidence and history, and the decision bar: clear, hold or revoke, each asking for a reason where needed. The signals and their wording are inferred: the PR mock has no fraud screen.

Code
import { useState } from 'react';
import { Card, FraudCaseDetail, FraudCaseRow, FraudDecisionBar, type FraudCase } from '@ergasti/bricks';
import { fraudCases } from './pr';

function Review() {
  const [open, setOpen] = useState<FraudCase>(fraudCases[0]);
  const [done, setDone] = useState(0);
  return (
    <div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(320px, 1fr))' }}>
      <Card>
        <ul className="kit-pr-queue" aria-label="Fraud review queue">{fraudCases.map((c) => <FraudCaseRow key={c.id} item={c} selected={c.id === open.id} onOpen={setOpen} />)}</ul>
      </Card>
      <Card>
        <FraudCaseDetail
          item={open}
          evidence={open.id === 1 ? {
            orders: [{ id: 1, ref: '#10482', buyer: 'O. K••• · +20 10•• ••• 471', commission: '620.00', placed: '12 Nov · 21:04', flag: 'Same phone as the creator' }],
            matches: [{ id: 'ip', what: 'ip', value: '41.33.•••.12', shared: ['Laila Mostafa', 'Ziad Hany'] }],
            timing: [{ id: 't', text: '3 orders within 12 minutes of the code going live' }],
          } : undefined}
          history={open.id === 1 ? [{ id: 2, tone: 'butter', title: 'Commission held automatically', at: '8 Nov · 10:02' }, { id: 1, tone: 'rasp', title: 'Case opened', at: '8 Nov · 10:01' }] : []}
          onOpenOrder={() => {}}
          actions={<FraudDecisionBar creatorName={open.creator.name} status={open.status} reasons={{ revoke: [{ value: 'confirmed', label: 'Confirmed self-purchase' }, { value: 'ring', label: 'Part of a shared-buyer ring' }] }} onDecide={() => setDone((n) => n + 1)} doneKey={done} />}
        />
      </Card>
    </div>
  );
}

Pills and the table preset

Signal and status pills, and fraudColumns for a DataTable of cases.

Code
import { DataTable, FraudSignalPill, FraudStatusPill, fraudColumns } from '@ergasti/bricks';
import { fraudCases } from './pr';

function Table() {
  return (
    <div style={{ display: 'grid', gap: 14 }}>
      <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap', alignItems: 'center' }}>
        <FraudSignalPill kind="self_referral" severity="high" /><FraudSignalPill kind="fraud_ring" severity="medium" /><FraudSignalPill kind="order_burst" severity="low" />
        <FraudStatusPill status="open" /><FraudStatusPill status="held" /><FraudStatusPill status="cleared" /><FraudStatusPill status="revoked" />
      </div>
      <DataTable label="Fraud cases" columns={fraudColumns('en', { onOpen: () => {} })} rows={fraudCases} rowKey={(r) => r.id} />
    </div>
  );
}

Detail loading and failed

The case's row is known, so FraudCaseDetail draws its header at once; loading holds the evidence and history as skeletons, and error with onRetry replaces them with the reason and Try again. onOpenCreator makes the creator's name a button.

Code
import { useState } from 'react';
import { Card, FraudCaseDetail } from '@ergasti/bricks';
import { fraudCases } from './pr';

function DetailStates() {
  const [failed, setFailed] = useState(false);
  return (
    <div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(320px, 1fr))' }}>
      <Card><FraudCaseDetail item={fraudCases[1]} loading onOpenCreator={() => {}} /></Card>
      <Card>
        <FraudCaseDetail item={fraudCases[2]} error={failed ? 'Still failing: the evidence service is down.' : 'The evidence could not be loaded.'} onRetry={() => setFailed(true)} onOpenCreator={() => {}} />
      </Card>
    </div>
  );
}

Decision saving, then failing

Press Revoke and confirm: the app sets pending to the decision while it saves (its dialog stays open, every button locked), then passes the server's error, shown inside the open dialog. On success the app bumps doneKey to close it.

Code
import { useState, type ReactNode } from 'react';
import { Button, FraudDecisionBar } from '@ergasti/bricks';

function DecisionStates() {
  const [pending, setPending] = useState<'clear' | 'hold' | 'revoke' | null>(null);
  const [error, setError] = useState<ReactNode>(null);
  const [done, setDone] = useState(0);
  return (
    <div style={{ display: 'grid', gap: 12, justifyItems: 'start' }}>
      <FraudDecisionBar
        creatorName="Omar Khaled" status="held" pending={pending} error={error} doneKey={done}
        onDecide={({ decision }) => {
          setError(null);
          setPending(decision);
          window.setTimeout(() => { setPending(null); setError('The server refused: this case was changed by Ahmed a moment ago.'); }, 1200);
        }}
      />
      <Button size="sm" variant="ghost" onClick={() => { setError(null); setDone((n) => n + 1); }}>Pretend it saved (close)</Button>
    </div>
  );
}

More signals in the row

maxSignals sets how many signal pills show before "+N more" (default 2).

Code
import { Card, FraudCaseRow } from '@ergasti/bricks';
import { fraudCases } from './pr';

function AllSignals() {
  return <Card><ul className="kit-pr-queue" aria-label="Fraud review queue"><FraudCaseRow item={fraudCases[0]} maxSignals={3} onOpen={() => {}} /></ul></Card>;
}

Props

Prop

Type

Design guidance

How the BRICKS design system uses FraudSignalPill. Written in docs/content/components/FraudSignalPill.md; the props above are read from the code, which wins where the two disagree.

A pill naming one fraud warning sign ("Self-purchase", "Same buyer on many codes") coloured by its severity; use it in the PR fraud review queue, table and case detail.

FraudSignalPill turns a signal key into words from the provider's statusTables.prFraud (falling back to FRAUD_SIGNALS, the PR admin's hold reasons and matcher arms). With a severity the pill is red, amber or grey and starts with a dot, and the severity is also in its accessible name and tooltip, so colour is never the only cue. Fraud review is inferred from the PR admin (the v3 mock draws no fraud screen).

Anatomy

  1. Wrapper: <span class="kit-pr-fsig"> with title="High severity" when a severity is set; never wider than its cell (long names wrap inside the pill, radius 13px).
  2. Pill: the kit Pill in the tone.
  3. Severity dot (with severity): a 7px currentColor dot, aria-hidden.
  4. Words: the signal's en / ar label (an unknown kind shows as itself).
  5. Hidden severity: " (High severity)" for screen readers.

Variants

severityToneLookMeaning
highbadred pill with a dotStrong evidence: act first
mediumwarnbutter pill with a dotWorth a look
lowmutegrey pill with a dotWeak on its own
nonethe signal's own toneno dotA legend or a filter chip

FRAUD_SIGNALS (own tone): self_referral Self-purchase (bad), cross_creator Bought with another creator's code (warn), address_match Shipped to a known address (warn), identity_match Buyer's phone or email matches the creator (bad), fraud_ring Same buyer on many codes (bad), gift_wrong_claimer Gift used by someone else (warn), duplicate_handle Duplicate Instagram or TikTok handle (warn), device_match Same device or IP as the creator (warn), order_burst Many orders in a short time (mute).

States

Static. Unknown kind: shows the key, mute (or the severity tone). Long name: wraps inside the pill.

Types

Also exported: FRAUD_SIGNALS and the types FraudSignal, FraudSignalKind, FraudCase, FraudCaseStatus, FraudDecision, FraudSeverity. Shared words (severity, status): provider labels.prFraud.

Usage

import { FraudSignalPill } from '@ergasti/bricks';

<FraudSignalPill kind="identity_match" severity="high" />
// A case's strongest two signals, then "+1 more"
<span style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
  {c.signals.slice(0, 2).map((s) => <FraudSignalPill key={s.kind} kind={s.kind} severity={s.severity} />)}
  {c.signals.length > 2 && <span className="kit-pr-muted">+{c.signals.length - 2} more</span>}
</span>
// An app's own signal, with words for both languages
<BricksProvider preset={trndrPreset} statusTables={{ prFraud: { refund_loop: { tone: 'warn', en: 'Refund after payout', ar: 'استرجاع بعد الدفع' } } }}>
  <FraudSignalPill kind="refund_loop" severity="medium" />
</BricksProvider>

Pills and the table preset. Signal and status pills, and fraudColumns for a DataTable of cases. (docs example Table)

import { Button, Card, DataTable, FraudCaseDetail, FraudCaseRow, FraudDecisionBar, FraudSignalPill, FraudStatusPill, fraudColumns, type FraudCase } from '@ergasti/bricks';
// fraudCases: the docs' sample rows (docs/examples/_pr.ts)

export function Table() {
  return (
    <div style={{ display: 'grid', gap: 14 }}>
      <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap', alignItems: 'center' }}>
        <FraudSignalPill kind="self_referral" severity="high" /><FraudSignalPill kind="fraud_ring" severity="medium" /><FraudSignalPill kind="order_burst" severity="low" />
        <FraudStatusPill status="open" /><FraudStatusPill status="held" /><FraudStatusPill status="cleared" /><FraudStatusPill status="revoked" />
      </div>
      <DataTable label="Fraud cases" columns={fraudColumns('en', { onOpen: () => {} })} rows={fraudCases} rowKey={(r) => r.id} />
    </div>
  );
}

Where it appears

Guidelines

Do

  • Sort signals strongest first and show two per row.
  • Pass a severity in queues; leave it out only in legends.
  • Add new kinds through statusTables.prFraud with both languages.

Don't

  • Don't put buyer data in the pill; put the detail beside it.
  • Don't use it for the case's status: use FraudStatusPill.

RTL and Arabic

The pill mirrors (dot at the inline start). Arabic labels come from the table ("شراء ذاتي", "نفس المشتري على أكتر من كود"); severity reads "خطورة عالي".

Tokens

--rasp-50, --bad, --butter, --butter-ink, --soft, --ink-2 (and the other kit-chip tones for app signals).

Accessibility

The severity is in the text for screen readers and in the tooltip; the dot is aria-hidden. Words carry the meaning; tone only repeats it.

Found in the source

  • ARIA attributes set: aria-hidden.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: Pill · useBricks · useLanguage · Card · FraudDecisionBar · DataTable · Button

Source

src/pr/fraud/FraudSignalPill.tsx (line 95) on GitHub.

On this page