Skip to Content
BBRICKSv0.7.4
PR PortalFraud review

FraudDecisionBar

The fraud case's decision buttons (inferred: the PR admin's clear / keep held / claw back actions): Clear, Hold and Revoke, each through the PR ReasonDialog with a required reason (a list when reasons gives one, else free text). Revoke is the raspberry, irreversible one. Nothing is decided until the dialog's confirm.

import { FraudDecisionBar } 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

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prFraudDecision, or with the component's own prop where it has one. A {name} is a value the component fills in.

prFraudDecision
KeyEnglishArabic
barDecisionالقرار
clearClearسليم
holdHoldوقّف
revokeRevokeالغي
clearTClear {n}?تقفل حالة {n} إنها سليمة؟
holdTHold {n}’s commission?توقّف عمولة {n}؟
revokeTRevoke {n}’s commission?تلغي عمولة {n}؟
clearSIt was a false alarm: the held commission is released and counts in the creator’s wallet again.كان إنذار غلط: العمولة المتوقفة هترجع وتتحسب في محفظة صانع المحتوى تاني.
holdSThe commission stays held while you look into it. Nothing is paid and nothing is taken back.العمولة هتفضل متوقفة لحد ما تخلّص مراجعتك. مفيش حاجة هتتدفع ولا هتترد.
revokeSThe commission is cancelled and the creator’s codes in this store stop working. This can’t be undone.العمولة هتتلغي وأكواد صانع المحتوى في المتجر ده هتقف. الخطوة دي مش بترجع.
clearCClear and releaseاقفلها وارجّع العمولة
holdCKeep on holdخليها متوقفة
revokeCRevoke commissionالغي العمولة

Design guidance

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

The fraud case's decision buttons, Clear, Hold and Revoke, each through a reason dialog; use it under a FraudCaseDetail.

FraudDecisionBar offers only the decisions the case's status allows: a new case can be cleared, held or revoked; a held case cleared or revoked; a decided case nothing (the bar renders nothing). Each button opens the PR ReasonDialog with the decision's title, consequence and confirm label; nothing is decided until the dialog's confirm. Revoke is the raspberry, irreversible one. Inferred from the PR admin's clear / keep held / claw back actions (no mock screen).

Anatomy

  1. Group: <div role="group" aria-label="Decision">, buttons end-aligned with 8px gaps (full width on phones).
  2. Clear (ink), Hold (default), Revoke (rasp) buttons, as allowed.
  3. Reason dialog: one at a time: title ("Revoke Omar Khaled's commission?"), consequence, a required reason (a list when reasons gives one, else free text), confirm ("Clear and release" / "Keep on hold" / "Revoke commission").

Variants

statusButtons
openClear, Hold, Revoke
heldClear, Revoke
cleared, revokednone (renders nothing)
DecisionButtonDialog confirmDialog toneWhat happens
clearinkClear and releaseinkHeld commission released to the wallet
holddefaultKeep on holdinkStays held while PR looks
revokeraspRevoke commissionraspCommission cancelled, codes in this store stop; can't be undone

States

StateTrigger
Idle—
Dialog opena button pressed
Pendingpending="revoke" (etc.): all buttons disabled, that dialog's confirm disabled
Errorerror: shown in the open dialog
Donebump doneKey after a successful save: the dialog closes

Types

FraudDecisionResult (onDecide): { decision, reason, note } after the dialog's confirm.

Usage

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

<FraudDecisionBar
  creatorName="Omar Khaled"
  status="held"
  reasons={{ revoke: [
    { value: 'self', label: 'Bought with their own code' },
    { value: 'ring', label: 'Part of a buyer ring' },
    { value: 'other', label: 'Other' },
  ] }}
  onDecide={async ({ decision, reason, note }) => {
    setPending(decision);
    try { await decideCase(caseId, decision, reason, note); setDone((n) => n + 1); }
    catch { setError("We couldn't save the decision."); }
    finally { setPending(null); }
  }}
  pending={pending}
  error={error}
  doneKey={done}
/>
// Passed to the case as its actions
<FraudCaseDetail item={openCase} evidence={evidence} history={caseHistory}
  actions={<FraudDecisionBar creatorName={openCase.creator.name} status={openCase.status} onDecide={decide} doneKey={done} />} />

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. (docs example DecisionStates)

import { useState, type ReactNode } from 'react';
import { Button, Card, DataTable, FraudCaseDetail, FraudCaseRow, FraudDecisionBar, FraudSignalPill, FraudStatusPill, fraudColumns, type FraudCase } from '@ergasti/bricks';

export 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>
  );
}

Where it appears

  • Library-only (no v3 mock screen): Fraud review › the open case's footer (inside FraudCaseDetail).

Guidelines

Do

  • Give Revoke a reason list so revocations are consistent and reportable.
  • Close the dialog only after the server confirms (doneKey), and keep it open with error on failure.
  • Refresh the case after a decision so the status pill and the allowed buttons change.

Don't

  • Don't add a Revoke shortcut outside the dialog: it cannot be undone.
  • Don't show the bar for a decided case (it renders nothing on its own).

RTL and Arabic

Buttons flow from the inline end. Arabic: "سليم", "وقّف", "الغي"; titles "تلغي عمولة {name}؟"; confirms "اقفلها وارجّع العمولة", "خليها متوقفة", "الغي العمولة".

Tokens

Button and ReasonDialog tokens (--ink, --rasp, --line, --focus-ring).

Accessibility

  • A labelled group ("Decision") of real buttons.
  • The dialogs are ReasonDialogs: focus trap, Escape, required reason with an explained error, role="alert" for failures.

Found in the source

  • Roles in the markup: group.
  • ARIA attributes set: aria-label.

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

See also: Button · useLanguage · Card · FraudCaseRow · FraudSignalPill · DataTable

Source

src/pr/fraud/FraudDecisionBar.tsx (line 77) on GitHub.

On this page