BrandGiftStockCard
A brand's gift stock in one card (the mock's "<brand> gift stock" on the shipment page and on a brand's challenge request): "Confirmed units left 42 / 100" and a note that claimed units do not count until confirmed.
import { BrandGiftStockCard } from '@ergasti/bricks';Examples
Count a shipment that is expected: tick a product that arrived in full ("All 40 OK") or enter the good and damaged units, then the boxes received
onConfirm gets whole numbers only.
Code
import { useState } from 'react';
import { GiftShipmentCard, type GiftCount } from '@ergasti/bricks';
function CountWhatArrived() {
const [last, setLast] = useState<GiftCount | null>(null);
return (
<div style={{ display: 'grid', gap: 10 }}>
<GiftShipmentCard brand="Glow Lab" state="expected" lines={[{ id: 'powder', product: 'Face powder', claimed: 40 }]} claimedBoxes={2} onConfirm={setLast} />
<small>{last ? `Confirmed: ${last.lines[0].good} good, ${last.lines[0].damaged} damaged, ${last.boxes} boxes` : 'Not confirmed yet'}</small>
</div>
);
}After the count: Missing per product, the difference banner, and the brand's problem report with "Keep the count" / "Recount"
Code
import { useState } from 'react';
import { GiftShipmentCard } from '@ergasti/bricks';
function ProblemReported() {
const [open, setOpen] = useState(true);
return (
<GiftShipmentCard
brand="Glow Lab" state="confirmed_diff"
lines={[{ product: 'Eyeshadow palette', claimed: 30, good: 28, damaged: 2 }, { product: 'Hand soap', claimed: 30, good: 26, damaged: 0 }]}
problem={open ? { date: '12 Nov', text: 'We packed 30 hand soaps in box 2. Please recount.' } : null} problemKept={!open}
onKeepCount={() => setOpen(false)} onRecount={() => setOpen(false)}
/>
);
}The shipment page's side column: when it was sent, arrived and confirmed, and the brand's confirmed gift stock
Code
import { BrandGiftStockCard, GiftShipmentTimeline } from '@ergasti/bricks';
function SideColumn() {
return (
<div style={{ display: 'grid', gap: 16, maxWidth: 420 }}>
<GiftShipmentTimeline sent="9 Nov · 3 boxes · Own driver" arrived="10 Nov · 3 of 3 boxes" confirmed="11 Nov" />
<BrandGiftStockCard brand="Glow Lab" left={42} total={100} />
</div>
);
}Counting while the shipment refetches
Pass shipmentId: what PR has typed is kept by product (the line's id, else its name), so a refetch that reorders the lines, adds one or moves the shipment from Expected to Arrived keeps each count with its product. Only another shipment id starts a new count. Type a count, then press Refetch.
Code
import { useState } from 'react';
import { Button, GiftShipmentCard, type GiftShipmentLine } from '@ergasti/bricks';
function RefetchKeepsTheCount() {
const first: GiftShipmentLine[] = [{ id: 'eye', product: 'Eyeshadow palette', claimed: 20 }, { id: 'lip', product: 'Red lipstick', claimed: 10 }];
const [lines, setLines] = useState(first);
return (
<div style={{ display: 'grid', gap: 10 }}>
<div><Button size="sm" onClick={() => setLines((l) => [{ id: 'oil', product: 'Lip oil', claimed: 5 }, ...[...l].reverse().filter((x) => x.id !== 'oil')])}>Refetch</Button></div>
<GiftShipmentCard shipmentId="GS-0016" brand="Glow Lab" state="arrived" lines={lines} onConfirm={() => {}} />
</div>
);
}Loading and failed loads
The claim page's cards take loading (skeleton lines under their heading) and a load error with Try again: loadError / onRetry on all four (error on GiftShipmentCard and WarehouseDetailsCard is a failed save).
Code (not run)
import { BrandGiftStockCard, GiftShipmentCard, GiftShipmentTimeline, WarehouseDetailsCard } from '@ergasti/bricks';
function LoadStates() {
return (
<div style={{ display: 'grid', gap: 16 }}>
<GiftShipmentCard brand="Glow Lab" state="expected" lines={[]} loading />
<div style={{ display: 'grid', gap: 16, maxWidth: 420 }}>
<GiftShipmentTimeline sent="" loading />
<BrandGiftStockCard brand="Glow Lab" left={0} loadError onRetry={() => {}} />
</div>
<WarehouseDetailsCard value={{ address: '', hours: '', phone: '' }} onSave={() => {}} loadError onRetry={() => {}} />
</div>
);
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prGiftSide, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
timeline | Timeline | الخط الزمني |
sentByBrand | Sent by brand | البراند بعتتها |
recordedBy | Recorded by {name} | سجّلها {name} |
arrived | Arrived | وصلت |
confirmed | Confirmed | اتأكدت |
notYet | Not yet | لسه |
stock | {brand} gift stock | مخزون هدايا {brand} |
left | Confirmed units left | الوحدات المتأكدة اللي فاضلة |
note | Claimed units are not counted here. A challenge with gifts can't go live until its gifts are confirmed. | الوحدات اللي البراند بلّغت عنها مش محسوبة هنا. التحدي اللي فيه هدايا ما يبدأش غير لما هداياه تتأكد. |
open | Gift stock → | مخزون الهدايا ← |
loading | Loading… | بنحمّل… |
loadError | Couldn’t load this. Try again. | مقدرناش نحمّل ده. جرّب تاني. |
retry | Try again | جرّب تاني |
Design guidance
How the BRICKS design system uses BrandGiftStockCard. Written in docs/content/components/BrandGiftStockCard.md; the props above are read from the code, which wins where the two disagree.
A small card with one brand's confirmed gift stock ("Confirmed units left 42 / 100") and the rule that claimed units do not count; use it beside a shipment or a brand's challenge request so PR sees what can still be given.
It is the side card of the PR Portal's shipment page (P.gship: "Glow Lab gift stock" under the Timeline) and of a brand's challenge request page (P.request, where the mock drops the total and adds a "Gift stock →" link). It reads only confirmed units: a challenge with gifts cannot go live until its gifts are counted and confirmed.
Anatomy
- Card (
Cardwith.kit-pr-gside, gap 12): a<section>named by its header. - Header:
Card.Headertitle "<brand> gift stock" (<h2>, display face 17px). - Figure row (
.kit-pr-kv, a<dl>): muted "Confirmed units left" at the start, the bold tabular figure at the end,dir="ltr"so "42 / 100" keeps its order.totalomitted: the figure alone ("1,240"). - Note (
.kit-pr-gnote--side, 12px muted): the default rule, yournote, or nothing (note={null}). - Link (optional,
.kit-pr-link): "Gift stock →" button after the note, whenonOpenGiftStockis set. - Extra (optional): any node after the note, such as an open
DecisionTag.
Variants
| Prop / value | Look | Use when |
|---|---|---|
total set | "42 / 100" | The shipment page: units left out of all confirmed units. |
total omitted | "1,240" | The brand request page (the mock shows the count alone). |
note omitted | Default rule: "Claimed units are not counted here. A challenge with gifts can't go live until its gifts are confirmed." | Most places. |
note a node | Your sentence | The request page's "…until its gifts are counted and confirmed." |
note={null} | No note (unless a link or extra is set) | Tight sidebars, the rule shown elsewhere. |
onOpenGiftStock set | Raspberry "Gift stock →" link after the note | When the page is not the Gift stock list itself. |
States
- Default: figure and note.
- No stock left:
left={0}reads "0 / 20"; there is no special tone, so say what it means innoteor near it. - Link hover / focus-visible: underline on hover; focus ring (
--focus-ring) on the link. - No loading, empty or error state of its own: render it once the stock is known.
Types
PrGiftSideCopy (labels): stock(brand), left, note, open, and the optional loading, loadError, retry; also reachable as labels.prGiftSide on the provider.
Usage
// PR Portal › Gift stock › GS-0017: the side column
function GiftShipmentPage({ onConfirm }: { onConfirm: (count: GiftCount) => void }) {
return (
<div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr', gap: 16 }}>
<GiftShipmentCard brand="Glow Lab" state="expected" lines={[{ product: 'Face powder', claimed: 40 }]} claimedBoxes={2}
onConfirm={onConfirm} onKeepCount={() => {}} onRecount={() => {}} />
<div style={{ display: 'grid', gap: 16, alignContent: 'start' }}>
<GiftShipmentTimeline sent="17 Nov · 2 boxes · Courier" />
<BrandGiftStockCard brand="Glow Lab" left={42} total={100} />
</div>
</div>
);
}// PR Portal › a brand's challenge request: count only, own note, link to the list
<BrandGiftStockCard
brand="Glow Lab"
left={1240}
note="A challenge with gifts can't go live until its gifts are counted and confirmed."
onOpenGiftStock={() => navigate('/gifts')}
extra={<DecisionTag id="GS1" />}
/>// No note at all
<BrandGiftStockCard brand="Kemet Home" left={0} total={20} note={null} />Where it appears
- PR Portal › Gift stock › a shipment (
GS-0017,GS-0016,GS-0014,GS-0009) › side column under Timeline. Gallery screensgifts-ship,gifts-ship-arrived,gifts-ship-problem,gifts-ship-confirmed. - PR Portal › Affiliate programs › Challenges › Brand requests › a request › "<brand> gift stock" card (mock
P.request). - Screen: PR · Gift stock shows the list it links back to.
Guidelines
Do
- Pass only confirmed units: claimed units in transit never count.
- Give
totalwhere PR compares against everything confirmed (the shipment page). - Add
onOpenGiftStockon pages away from the Gift stock list.
Don't
- Don't use it for Brand detail's three figures (Units left, Delivered, Not delivered yet): use
BrandGiftStock. - Don't format
leftyourself; pass a number so Arabic digits and grouping come from the language. - Don't stack two of these for the same brand on one page.
RTL and Arabic
- Label and figure swap sides; the figure stays
dir="ltr"so "42 / 100" never reverses. - Arabic copy: "مخزون هدايا <brand>", "الوحدات المتأكدة اللي فاضلة"; the arrow in "مخزون الهدايا ←" points the reading way.
- Numbers use the language's digits through
count().
Tokens
--card, --line, --r-lg, --ink, --ink-3, --rasp, --focus-ring, --radius-xs, --min-touch-target, --font-family-display.
Accessibility
- A
<section>named by its "<brand> gift stock" heading; the figure is a<dl>pair, read as "Confirmed units left, 42 / 100". - "Gift stock →" is a real
<button>(.kit-pr-link) with a visible focus ring; at 1024px and below a transparent::beforegrows its hit area to 44px (--min-touch-target). - The note is muted ink (
--ink-3) on--card, small text: keep it to one or two sentences.
Found in the source
- ARIA attributes set:
aria-hidden. - Its tests cover: “the request page variant: the figure alone, its own note and a ”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
BrandGiftStock: Brand detail's Gift stock card with three figures and a link to requests.GiftShipmentTimeline: the card stacked above it on the shipment page.GiftShipmentCard: the shipment's main card.GiftStockList/ PR · Gift stock: the Gift stock list the link opens.
See also: Card · useLanguage · Button · WarehouseDetailsCard · GiftAttentionList · GiftClaimCheck · GiftShipmentCounts
Source
src/pr/gifts/GiftSideCards.tsx (line 120) on GitHub.