GiftShipmentCounts
Gift analytics' "Shipments from brands" card body: one line per shipment status (its pill, the count at the end, a hairline between) and "1 problem report open" under them. Read-only: the Gift stock list is where a status is filtered. The card and its heading are the screen's (Card + Card.Header).
import { GiftShipmentCounts } from '@ergasti/bricks';Examples
Shipments from brands
One line per shipment status (its pill and the count) and the open problem reports under them; the card and its heading are yours.
Code
import { Card, GiftShipmentCounts } from '@ergasti/bricks';
function Shipments() {
return (
<Card>
<Card.Header title="Shipments from brands" />
<GiftShipmentCounts counts={{ gift_expected: 3, gift_arrived: 2, gift_confirmed: 1, gift_confirmed_diff: 1 }} problems={1} />
</Card>
);
}Gift stock by brand
giftBrandColumns draws the brand, the stock used bar ("58/100", also UsageBar on its own), sent, delivered with its rate, received vs claimed and the stock pill (OK, Running low, Out of gifts).
Code
import { DataTable, UsageBar, giftBrandColumns, type GiftBrandRow } from '@ergasti/bricks';
const rows: GiftBrandRow[] = [
{ id: 'glow', name: 'Glow Lab', color: '#C7325C', used: 58, total: 100, delivered: 38, notDelivered: 20, received: 97 },
{ id: 'mira', name: 'Mira Beauty', color: '#5B3BB0', used: 30, total: 30, delivered: 24, notDelivered: 6, received: null },
{ id: 'nile', name: 'Nile Threads', color: '#2C45A6', used: 22, total: 40, delivered: 15, notDelivered: 7, received: null },
];
function ByBrand() {
return (
<div style={{ display: 'grid', gap: 16 }}>
<DataTable label="Gift stock by brand" rows={rows} rowKey={(r) => r.id} columns={giftBrandColumns('en')} onRowClick={() => {}} />
<div style={{ width: 240 }}><UsageBar used={16} total={25} /></div>
</div>
);
}The page around them
Stat tiles are KpiCard (icon, tone, sub line, progress); "Needs attention" is RowItems with a BrandCell whose title names the shipment.
Code
import { BrandCell, KpiCard, KpiGrid, RowItems } from '@ergasti/bricks';
function Page() {
return (
<div style={{ display: 'grid', gap: 16 }}>
<KpiGrid>
<KpiCard tone="lime" icon="gift" label="Confirmed gift stock" value={195} sub="69 units left to pick" progress={65} />
<KpiCard tone="lilac" icon="check" label="Delivered" value={89} sub="71% delivery rate · 37 not yet" progress={71} />
</KpiGrid>
<RowItems label="Needs attention" items={[
{ id: 'mira', lead: <BrandCell name="Mira Beauty" color="#5B3BB0" sub="Out of gifts · ask for more stock" />, onSelect: () => {} },
{ id: 'gs17', lead: <BrandCell name="Glow Lab" color="#C7325C" title="GS-0017 · Glow Lab" sub="40 units to check · Expected" />, onSelect: () => {} },
]} />
</div>
);
}The stock rule on its own
giftStockStatus(used, total) is the mock's rule as a status key: gift_out when nothing is left, gift_low under 20% left, else gift_ok. Use it with PrStatusPill and UsageBar where you draw stock outside giftBrandColumns, so every screen agrees on "Running low".
Code
import { Card, PrStatusPill, UsageBar, giftStockStatus, type GiftBrandRow } from '@ergasti/bricks';
const rows: GiftBrandRow[] = [
{ id: 'glow', name: 'Glow Lab', color: '#C7325C', used: 58, total: 100, delivered: 38, notDelivered: 20, received: 97 },
{ id: 'mira', name: 'Mira Beauty', color: '#5B3BB0', used: 30, total: 30, delivered: 24, notDelivered: 6, received: null },
{ id: 'nile', name: 'Nile Threads', color: '#2C45A6', used: 22, total: 40, delivered: 15, notDelivered: 7, received: null },
];
function StockRule() {
const rows = [['Glow serum set', 58, 100], ['Kemet candle', 86, 100], ['Nile tote', 40, 40]] as const;
return (
<Card>
<ul style={{ listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: 12 }}>
{rows.map(([name, used, total]) => (
<li key={name} style={{ display: 'grid', gridTemplateColumns: '1fr 140px auto', gap: 16, alignItems: 'center' }}>
<b>{name}</b>
<UsageBar used={used} total={total} />
<PrStatusPill status={giftStockStatus(used, total)} />
</li>
))}
</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 prGiftAnalytics, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
brand | Brand | البراند |
used | Stock used | اللي اتصرف من المخزون |
sent | Sent | اتبعت |
delivered | Delivered | اتسلّم |
received | Received vs claimed | اللي وصل قصاد اللي اتقال |
status | Status | الحالة |
deliveredOf | {percent}% delivered | اتسلّم {percent}% |
notCounted | Nothing counted yet | لسه متعدّش حاجة |
shipments | Shipments by status | الشحنات حسب الحالة |
problems | {shown2} problem reports open | {shown2} بلاغ مشكلة مفتوح |
Design guidance
How the BRICKS design system uses GiftShipmentCounts. Written in docs/content/components/GiftShipmentCounts.md; the props above are read from the code, which wins where the two disagree.
The body of Gift analytics' "Shipments from brands" card: one line per shipment status with its pill and count, and the number of open problem reports; use it inside a Card on the Gift analytics page.
GiftShipmentCounts summarises the shipments brands have sent to the TRNDR warehouse by status: Expected, Arrived, Confirmed and Confirmed with difference, each a PrStatusPill with its count at the end, ruled between. Under the list a muted line says how many problem reports are open ("1 problem report open"). It is read-only: filtering by status happens on the Gift stock list. The card and its heading belong to the screen.
Anatomy
- List:
<ul aria-label="Shipments by status" class="kit-pr-gcounts">, one<li>per status:PrStatusPillat the start, the count bold at the end (dir="ltr"), 8px block padding, a top rule. - Problems line (when
problemsis given): 12.5px--ink-3, 10px above.
Variants
| Prop | Value | Effect |
|---|---|---|
statuses | default ['gift_expected', 'gift_arrived', 'gift_confirmed', 'gift_confirmed_diff'] | Which statuses to list, in order |
problems | undefined | Hides the problems line |
0 | "No problem reports open" | |
1 / n | "1 problem report open" / "{n} problem reports open" |
States
Static. A status missing from counts shows 0.
Types
GiftShipmentStatus: 'gift_expected' | 'gift_arrived' | 'gift_confirmed' | 'gift_confirmed_diff'.
Usage
import { Card, GiftShipmentCounts } from '@ergasti/bricks';
<Card>
<Card.Header title="Shipments from brands" />
<GiftShipmentCounts counts={{ gift_expected: 3, gift_arrived: 2, gift_confirmed: 1, gift_confirmed_diff: 1 }} problems={1} />
</Card>// Gift analytics: the side column beside "By brand"
<div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr', gap: 16 }}>
<Card title="By brand"><DataTable label="Gift stock by brand" rows={brands} rowKey={(b) => b.id} columns={giftBrandColumns('en')} chevron={false} onRowClick={openBrand} /></Card>
<div style={{ display: 'grid', gap: 16 }}>
<Card title="Needs attention"><RowItems label="Needs attention" items={attention} /></Card>
<Card><Card.Header title="Shipments from brands" /><GiftShipmentCounts counts={counts} problems={openProblems} /></Card>
</div>
</div>Shipments from brands. One line per shipment status (its pill and the count) and the open problem reports under them; the card and its heading are yours. (docs example Shipments)
import { BrandCell, Card, DataTable, GiftShipmentCounts, KpiCard, KpiGrid, PrStatusPill, RowItems, UsageBar, giftBrandColumns, giftStockStatus, type GiftBrandRow } from '@ergasti/bricks';
export function Shipments() {
return (
<Card>
<Card.Header title="Shipments from brands" />
<GiftShipmentCounts counts={{ gift_expected: 3, gift_arrived: 2, gift_confirmed: 1, gift_confirmed_diff: 1 }} problems={1} />
</Card>
);
}Where it appears
- PR Portal › Gift analytics › "Shipments from brands" card (right column).
- Dashboard screen: PrGiftAnalytics.
Guidelines
Do
- Count shipments, not units; the units live on the Gift stock page.
- Show
problemswhenever the brand can dispute counts, even at 0 ("No problem reports open" reassures). - Link the card header to the Gift stock list if PR needs to act.
Don't
- Don't make the rows clickable filters; it is a summary.
- Don't add statuses outside the shipment flow (
gift_problemis counted in the problems line).
RTL and Arabic
Rows mirror (pill on the right, count on the left); counts keep dir="ltr". Arabic problems line uses the dual and plural forms: "بلاغ مشكلة واحد مفتوح", "بلاغين مشاكل مفتوحين", "{n} بلاغات مشاكل مفتوحة".
Tokens
--line, --ink-3, plus PrStatusPill's tone tokens (--sky, --lilac, --ok-bg, --butter).
Accessibility
A labelled list ("Shipments by status"); each row reads the status word then the count. The problems line is plain text.
Found in the source
- ARIA attributes set:
aria-hidden,aria-label. - Its tests cover: “Arabic + RTL: the figure stays left-to-right, the sentence is Arabic, and labels override it”; “keyboard: a row opens the brand on Enter (DataTable onRowClick)”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
GiftStatusPills: a shipment's status in a table row.ShipmentSummary: one shipment's claimed vs counted units.UsageBar/giftBrandColumns: the By brand table on the same page.
See also: useLanguage · BrandCell · PrStatusPill · Card · DataTable · KpiGrid · KpiCard · RowItems · BrandGiftStockCard · GiftAttentionList · GiftClaimCheck · GiftShipmentCard
Source
src/pr/ganalytics/GiftAnalytics.tsx (line 134) on GitHub.