Skip to Content
BBRICKSv0.7.4
PR PortalGifts

GiftShipmentCard

The PR mock v3's shipment card (P.gship's left card): "What Glow Lab says it sent vs what arrived" with the state pill, the product table and what PR does next, by state:

  • expected / arrived: the check table. "Arrived in full?" ticks a row ("All 40 OK"): its Good units become the claim, Damaged 0, both lock and the row is tinted; unticking clears Good and puts focus there. "Tick all as received in full", the explanation, "Boxes received" (expected only, with "Glow Lab said 2") and "Confirm received quantities", which checks every field (an inline alert names the problem, the bad fields are marked) before onConfirm. - confirmed / confirmed_diff: Good, Damaged and Missing ("+2 extra" when more arrived), then the matched line or the butter "You confirmed 54 of the 60 units…" banner. - problem: the brand's report in a red banner with "Keep the count" / "Recount" (any state).
import { GiftShipmentCard } 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 prGiftShipment, or with the component's own prop where it has one. A {name} is a value the component fills in.

prGiftShipment
KeyEnglishArabic
saysWhat {brand} says it sentاللي {brand} بتقول إنها بعتته
saysVsWhat {brand} says it sent vs what arrivedاللي {brand} بتقول إنها بعتته واللي وصل فعلاً
productProductالمنتج
claimedBrand says sentالبراند بتقول بعتت
inFullArrived in full?وصل كامل؟
goodGoodسليم
damagedDamagedتالف
missingMissingناقص
allOkAll {n} OKالـ {n} كلهم تمام
goodOfGood units of {product}الوحدات السليمة من {product}
damagedOfDamaged units of {product}الوحدات التالفة من {product}
extra+{n} extra+{n} زيادة
missingN{n} missing{n} ناقصين
checkCheck what arrived · {n} productsراجع اللي وصل · {n} منتجات
tickAllTick all as received in fullعلّم الكل إنه وصل كامل
explainTick each product that arrived in full and undamaged. If a count is off, leave it unticked and enter the good and damaged units you actually received. Units that can't be gifted go under Damaged. Only good units go into {brand}'s gift stock.علّم على كل منتج وصل كامل ومن غير تلف. لو العدد مش مظبوط، سيبه من غير علامة واكتب الوحدات السليمة والتالفة اللي استلمتها فعلاً. الوحدات اللي ما تنفعش هدية تتكتب في التالف. الوحدات السليمة بس هي اللي بتدخل مخزون هدايا {brand}.
boxesBoxes receivedالكراتين اللي وصلت
said{brand} said {n}{brand} قالت {n}
confirmConfirm received quantitiesأكّد الكميات اللي وصلت
boxesErrBoxes received must be a whole number from 1 to 99عدد الكراتين لازم يكون رقم صحيح من 1 لـ 99
unitsErrEnter the good and damaged units for every product (0 to 999)اكتب الوحدات السليمة والتالفة لكل منتج (من 0 لـ 999)
unitsErrUpToEnter the good and damaged units for every product (0 to {max})اكتب الوحدات السليمة والتالفة لكل منتج (من 0 لـ {max})
problem{brand} reported a problem{brand} بلّغت عن مشكلة
keepKeep the countخلّي العدد زي ما هو
recountRecountعِدّ تاني
kept{brand}'s problem report was closed: the count stands.بلاغ {brand} اتقفل: العدد زي ما هو.
diffYou confirmed {good} of the {claimed} units {brand} claimed. Only {good} are in stock. {brand} sees the difference and can report a problem.أكّدت {good} من الـ {claimed} وحدة اللي {brand} قالت عليهم. {good} بس اللي في المخزون. {brand} بتشوف الفرق وتقدر تبلّغ عن مشكلة.
matchedAll {good} units matched the claim and are in {brand}'s gift stock.الـ {good} وحدة كلهم طابقوا اللي اتقال وبقوا في مخزون هدايا {brand}.
loadingLoading the shipment…بنحمّل الشحنة…
loadErrorCouldn’t load this shipment. Try again.مقدرناش نحمّل الشحنة دي. جرّب تاني.
retryTry againجرّب تاني

Design guidance

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

The shipment page's main card: what a brand says it sent against what arrived, the count PR enters, and what happens next by state; use it on the PR Portal's Shipment page.

GiftShipmentCard is the PR mock v3's P.gship left card ("What Glow Lab says it sent vs what arrived"). A brand claims it shipped gifts; nothing is gift stock until PR counts what arrived and confirms it, and only good units go into the brand's stock. While the shipment is Expected or Arrived the card is a check table: tick "All 40 OK" or type good and damaged units, enter boxes received (Expected only) and confirm. Once counted it shows Good, Damaged and Missing with the matched line or a difference banner. A brand's problem report shows above any state with "Keep the count" and "Recount". It fetches nothing; actions come back through callbacks.

Anatomy

  1. Card head: the title ("What Glow Lab says it sent" or "… vs what arrived") and the state's PrStatusPill.
  2. Table (bordered, radius 18): Product (row header, <bdi>), Brand says sent; while counting: Arrived in full? (checkbox "All 40 OK"), Good and Damaged inputs (72 × 42, numeric); once counted: Good (bold), Damaged, Missing (red count, or "+2 extra").
  3. Problem report (with problem): red Banner "Glow Lab reported a problem (12 Nov): "…"", then Keep the count / Recount (ink).
  4. Kept line (problemKept): "Glow Lab's problem report was closed: the count stands."
  5. Check block (counting): "Check what arrived · 2 products" with "Tick all as received in full"; the explanation (+ note); "Boxes received" field (Expected) with the hint "Glow Lab said 2"; inline errors; "Confirm received quantities" (ink).
  6. Result (counted): confirmed: "All 80 units matched the claim and are in Glow Lab's gift stock."; confirmed_diff: butter banner "You confirmed 54 of the 60 units Glow Lab claimed…".

Under 600px each product becomes a small card with its column labels.

Variants

stateWhat it shows
expectedCheck table, explanation, Boxes received, Confirm
arrivedCheck table, explanation, Confirm (no boxes)
confirmedCounted table, matched line
confirmed_diffCounted table, difference banner
cancelledClaimed units only
+ problemRed report banner and Keep / Recount, over any state
+ problemKeptMuted "count stands" line

States

StateTrigger
Row tickedcheckbox on: Good = claimed, Damaged = 0, both read-only, row lime-tinted
Row untickedGood cleared and focused
Invalid countConfirm with a non-whole or out-of-range value (0-999): fields marked aria-invalid, alert "Enter the good and damaged units for every product (0 to 999)"
Invalid boxesnot 1-99: field error
Busybusy: Keep, Recount and Confirm disabled
Save errorerror: alert above Confirm
New shipmentstate or line ids/claims change: the count resets
Arabic digitstyped Arabic-Indic digits are accepted

Types

GiftShipmentState (state): 'expected' | 'arrived' | 'confirmed' | 'confirmed_diff' | 'cancelled'. GiftShipmentLine (lines): { id?, product, claimed, good?, damaged? }. GiftProblem (problem): { date, text }: the open report. GiftCount (onConfirm, valid counts only): { lines: [{ id, good, damaged }], boxes? }.

Usage

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

<GiftShipmentCard
  brand="Glow Lab"
  state="expected"
  lines={[{ id: 'powder', product: 'Face powder', claimed: 40 }]}
  claimedBoxes={2}
  onConfirm={(count) => confirmShipment('GS-0017', count)}
  busy={saving}
  error={saveError}
/>
// Shipment page: the card beside the timeline and the brand's gift stock
<PageHeader title="GS-0014 · Glow Lab" subtitle="Sent 10 Nov · 3 boxes" />
<div style={{ display: 'grid', gridTemplateColumns: 'minmax(0, 2fr) minmax(0, 1fr)', gap: 16, alignItems: 'start' }}>
  <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={{ date: '12 Nov', text: 'We packed 30 hand soaps in box 2. Please recount.' }}
    onKeepCount={keepCount}
    onRecount={recount}
  />
  <div style={{ display: 'grid', gap: 16 }}>
    <GiftShipmentTimeline sent="10 Nov · 3 boxes · Courier" />
    <BrandGiftStockCard brand="Glow Lab" left={42} total={100} />
  </div>
</div>

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

import { useState } from 'react';
import { BrandGiftStockCard, GiftShipmentCard, GiftShipmentTimeline, type GiftCount } from '@ergasti/bricks';

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

Where it appears

  • PR Portal › Gift stock › a shipment's page (P.gship) › left card, in every state (GS-0017 expected, GS-0016 arrived, GS-0014 confirmed with difference and problem, GS-0009 confirmed).
  • Opened from PR Portal › Gift stock › shipments table row.
  • Dashboard screen: PrGifts (the list); the shipment page is a gallery screen.

Guidelines

Do

  • Re-send the shipment after onConfirm succeeds so the card moves to the counted state.
  • Keep "Damaged" for units that arrived but can't be gifted; missing is computed.
  • Put an open decision or a rules link in note, not in your own paragraph.

Don't

  • Don't count claimed units as stock anywhere else in the UI.
  • Don't hide the problem banner once the count is confirmed: the brand's report stays until PR answers.
  • Don't mix it with the deprecated GiftClaimCheck on the same page.

RTL and Arabic

Table and banners mirror; number inputs stay dir="ltr". Table heads drop upper-casing in Arabic. Arabic words: "وصل كامل؟", "سليم", "تالف", "ناقص", "الـ 40 كلهم تمام", "أكّد الكميات اللي وصلت"; Arabic-Indic digits typed into the fields are accepted.

Tokens

--line, --card, --tbl-head, --ink, --ink-3, --lime-50, --ok, --rasp, --bad, --field-radius, --focus-ring, --focus-ring-field, --radius-xs, --min-touch-target.

Accessibility

  • A real <table> with scope headers; each input is named ("Good units of Face powder"), the checkbox carries the product in hidden text.
  • A Missing count is a bold number, aria-hidden, with visually hidden "6 missing" text, so it is read with its meaning.
  • Invalid inputs are aria-invalid and point to the alert (aria-describedby); errors are role="alert".
  • Unticking moves focus to Good so PR can type at once.
  • Checkbox labels get a focus ring and, on touch, 44px targets.

Found in the source

  • Roles in the markup: alert.
  • ARIA attributes set: aria-label, aria-invalid, aria-describedby, aria-hidden.
  • It moves focus in code.
  • Its tests cover: “a tick fills Good with the claim, locks both and tints the row; unticking clears Good and focuses it”; “an untouched ”.

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

See also: Banner · Button · Card · FormField · useLanguage · PrStatusPill · WarehouseDetailsCard · GiftAttentionList · GiftShipmentCounts

Source

src/pr/gifts/GiftShipmentCard.tsx (line 181) on GitHub.

On this page