useGiftAnalyticsCopy
The Gift analytics blocks' words with the BricksProvider's labels.prGiftAnalytics over them (and own over both); pass it to giftBrandColumns.
import { useGiftAnalyticsCopy } 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>
);
}Signature
function useGiftAnalyticsCopy(language?: Lang | undefined, own?: Partial<{ readonly brand: string; readonly used: string; readonly sent: string; readonly delivered: string; readonly received: string; readonly status: string; readonly deliveredOf: (percent: string) => string; readonly notCounted: string; readonly shipments: string; readonly problems: (n: number, shown: string) => string; }> | undefined): { readonly brand: string; readonly used: string; readonly sent: string; readonly delivered: string; readonly received: string; readonly status: string; readonly deliveredOf: (percent: string) => string; readonly notCounted: string; readonly shipments: string; readonly problems: (n: number, shown: string) => string; }Parameters
Prop
Type
Returns
{ readonly brand: string; readonly used: string; readonly sent: string; readonly delivered: string; readonly received: string; readonly status: string; readonly deliveredOf: (percent: string) => string; readonly notCounted: string; readonly shipments: string; readonly problems: (n: number, shown: string) => string; }
Related
useLanguage · BrandCell · PrStatusPill · UsageBar · Card · GiftShipmentCounts · DataTable · KpiGrid · KpiCard · RowItems · useCampaignColumnsCopy · useGiftColumnsCopy · usePrColumnsCopy
Source
src/pr/ganalytics/GiftAnalytics.tsx (line 35) on GitHub.