Helpers and constants
Functions, constants and classes that have no page of their own.
Functions, constants and classes exported from @ergasti/bricks that have no page of their own. Components and hooks each have a page.
auditColumns
function
The audit log table's columns for DataTable: what happened, area, who, when. Labels come in the given language; sort keys are named after the AuditEntry fields.
function auditColumns(language: Lang, copy?: Partial<PrColumnsCopy> | undefined): DataColumn<AuditEntry>[]Prop
Type
Source: src/pr/presets.tsx (line 227)
Join requests table
The column preset gives the creator, followers, brand, source, waiting time and the approve and reject buttons, in the page's language; you give the handlers and the rows. The preset's sort keys are named after the row fields.
Code
import { useState } from 'react';
import { DataTable, joinRequestColumns } from '@ergasti/bricks';
import { joinRequests } from './pr';
function JoinRequests() {
const [selected, setSelected] = useState<ReadonlySet<string | number>>(new Set([1, 2]));
return (
<DataTable
label="Join requests" rows={joinRequests} rowKey={(r) => r.id}
columns={joinRequestColumns('en', { onApprove: () => {}, onReject: () => {}, onOpen: () => {} })}
selection={{ selected, onChange: setSelected, rowLabel: (r) => r.creator.name }}
sort={{ key: 'waiting', dir: 'desc' }} onSort={() => {}}
/>
);
}The other presets
Brands, payouts (with a receipt button), wallet top-ups (with a confirm button), announcements and the audit log: each is xColumns(language, handlers) returning DataColumn<Row>[] for DataTable.
Code
import { DataTable, auditColumns, brandColumns, messageColumns, payoutColumns, topUpColumns } from '@ergasti/bricks';
import { auditEntries, brandRows, messages, payouts, topUps } from './pr';
function MorePresets() {
return (
<div style={{ display: 'grid', gap: 24 }}>
<DataTable label="Brands" rows={brandRows} rowKey={(r) => r.id} columns={brandColumns('en')} onRowClick={() => {}} />
<DataTable label="Payouts" rows={payouts} rowKey={(r) => r.id} columns={payoutColumns('en', { onReceipt: () => {} })} />
<DataTable label="Top-ups" rows={topUps} rowKey={(r) => r.id} columns={topUpColumns('en', { onConfirm: () => {} })} />
<DataTable label="Messages" rows={messages} rowKey={(r) => r.id} columns={messageColumns('en')} onRowClick={() => {}} />
<DataTable label="Audit log" rows={auditEntries} rowKey={(r) => r.id} columns={auditColumns('en')} />
</div>
);
}BRAND_FEE_MAX
constant
The highest fee a brand may get, in percent.
const BRAND_FEE_MAX: 50Source: src/pr/brand/BrandFeeDialog.tsx (line 39)
Change PR owner
The select starts on the current owner and marks you; saving the same person says so instead of calling onSave. value is null for a brand nobody owns yet (or an id no longer in owners): the select then starts on "Choose the new owner". Controlled by open; the choice resets each time it opens.
Code
import { Button, ChangeOwnerDialog } from '@ergasti/bricks';
import { useState } from 'react';
const PRS = [{ id: 'mona', name: 'Mona Adel' }, { id: 'farida', name: 'Farida Nabil' }, { id: 'ahmed', name: 'Ahmed Samy' }];
function ChangeOwner() {
const [open, setOpen] = useState(false);
const [owner, setOwner] = useState<string | number | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Change</Button>
<small>Owner: {PRS.find((p) => p.id === owner)?.name ?? 'nobody yet'}</small>
<ChangeOwnerDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" owners={PRS} value={owner} meId="mona" onSave={(id) => { setOwner(id); setOpen(false); }} />
</div>
);
}Adjust wallet
An amount that is not 0 with up to two decimals (a minus sign takes money out) and a reason. The field asks for a text keyboard, so a phone shows the minus key. The amount is parsed in cents by parseWalletAdjustment (exported for your own checks: "-390.1" gives "-390.10"; 0, "1.005" and "+-5" give null), so onSave gets an exact 2-dp string; with available the dialog shows what the wallet holds after it. Try 0, 1.005 or −390.10.
Code
import { AdjustWalletDialog, Button, type WalletAdjustment } from '@ergasti/bricks';
import { useState } from 'react';
function AdjustWallet() {
const [open, setOpen] = useState(false);
const [last, setLast] = useState<WalletAdjustment | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Adjust wallet</Button>
<small>{last ? `Saved ${last.amount}: ${last.reason}` : 'Nothing saved yet'}</small>
<AdjustWalletDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" available="43390.00" money={{ decimals: 'auto' }} onSave={(a) => { setLast(a); setOpen(false); }} />
</div>
);
}TRNDR fee
0 to BRAND_FEE_MAX (50) % with up to two decimals, checked by parseBrandFee ("7.5" gives "7.50", "50.01" gives null). "Use default (5%)" shows while the brand has its own fee, and saving an empty field uses the default too; without onUseDefault an empty field is an error. A failed save shows error; busy locks the buttons.
Code
import { BrandFeeDialog, Button } from '@ergasti/bricks';
import { useState } from 'react';
function Fee() {
const [open, setOpen] = useState(false);
const [fee, setFee] = useState<string | null>('7.5');
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Change fee</Button>
<small>Fee: {fee === null ? '5% (default)' : `${fee}%`}</small>
<BrandFeeDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" value={fee} defaultFee="5" onSave={(v) => { setFee(v); setOpen(false); }} onUseDefault={() => { setFee(null); setOpen(false); }} />
</div>
);
}Arabic
Code
import { AdjustWalletDialog, Button } from '@ergasti/bricks';
import { useState } from 'react';
function Arabic() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>عدّل المحفظة</Button>
<AdjustWalletDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" available="43390.00" onSave={() => setOpen(false)} language="ar" />
</>
);
}brandColumns
function
The brandColumns DataTable column preset. money: how its money cells are shown (slot presets.figures, over the provider).
function brandColumns(language: Lang, copy?: Partial<PrColumnsCopy> | undefined, money?: MoneyDisplay | undefined): DataColumn<BrandRow>[]Prop
Type
Source: src/pr/presets.tsx (line 124)
Join requests table
The column preset gives the creator, followers, brand, source, waiting time and the approve and reject buttons, in the page's language; you give the handlers and the rows. The preset's sort keys are named after the row fields.
Code
import { useState } from 'react';
import { DataTable, joinRequestColumns } from '@ergasti/bricks';
import { joinRequests } from './pr';
function JoinRequests() {
const [selected, setSelected] = useState<ReadonlySet<string | number>>(new Set([1, 2]));
return (
<DataTable
label="Join requests" rows={joinRequests} rowKey={(r) => r.id}
columns={joinRequestColumns('en', { onApprove: () => {}, onReject: () => {}, onOpen: () => {} })}
selection={{ selected, onChange: setSelected, rowLabel: (r) => r.creator.name }}
sort={{ key: 'waiting', dir: 'desc' }} onSort={() => {}}
/>
);
}The other presets
Brands, payouts (with a receipt button), wallet top-ups (with a confirm button), announcements and the audit log: each is xColumns(language, handlers) returning DataColumn<Row>[] for DataTable.
Code
import { DataTable, auditColumns, brandColumns, messageColumns, payoutColumns, topUpColumns } from '@ergasti/bricks';
import { auditEntries, brandRows, messages, payouts, topUps } from './pr';
function MorePresets() {
return (
<div style={{ display: 'grid', gap: 24 }}>
<DataTable label="Brands" rows={brandRows} rowKey={(r) => r.id} columns={brandColumns('en')} onRowClick={() => {}} />
<DataTable label="Payouts" rows={payouts} rowKey={(r) => r.id} columns={payoutColumns('en', { onReceipt: () => {} })} />
<DataTable label="Top-ups" rows={topUps} rowKey={(r) => r.id} columns={topUpColumns('en', { onConfirm: () => {} })} />
<DataTable label="Messages" rows={messages} rowKey={(r) => r.id} columns={messageColumns('en')} onRowClick={() => {}} />
<DataTable label="Audit log" rows={auditEntries} rowKey={(r) => r.id} columns={auditColumns('en')} />
</div>
);
}campaignColumns
function
The Affiliate programs › Campaigns table as a DataTable column preset (the v3 mock's P.programs): brand; active campaign with its dates; program status; waiting requests as a butter "2 waiting" pill or a dash; commission; creators, sales · 30 days and orders (figures, end-aligned); last change, muted. Sort keys: name, campaign, waiting, creators, sales, orders. The trailing › comes from DataTable's onRowClick. money: slot presets.figures. options.wrap: let the long cells wrap like the v3 mock (default: one line each).
function campaignColumns(language: Lang, copy?: Partial<{ readonly brand: string; readonly campaign: string; readonly status: string; readonly requests: string; readonly commission: string; readonly creators: string; readonly sales: string; readonly orders: string; readonly lastChange: string; readonly range: (from: string, to: string) => string; readonly waiting: (n: string) => string; readonly none: string; }> | undefined, money?: MoneyDisplay | undefined, options?: CampaignColumnsOptions): DataColumn<CampaignRow>[]Prop
Type
Source: src/pr/programs/campaignColumns.tsx (line 77)
The Campaigns tab
One row per brand with its active campaign; waiting requests show as a pill. Rows open the campaign page.
Code
import { DataTable, campaignColumns, useCampaignColumnsCopy, type CampaignRow } from '@ergasti/bricks';
const ROWS: CampaignRow[] = [
{ id: 'glow', brand: { id: 'glow', name: 'Glow Lab', color: '#C7325C' }, campaign: { name: 'Winter glow 2026', from: '1 Nov 2026', to: '31 Jan 2027' }, status: 'active', waiting: 2, commission: '10% of sale', creators: 86, sales: '412300.00', orders: 1284, lastChange: 'Since 1 Oct 2026' },
{ id: 'nile', brand: { id: 'nile', name: 'Nile Threads', color: '#2C45A6' }, campaign: { name: 'Nile autumn', from: '12 Oct 2026', to: '31 Dec 2026' }, status: 'active', waiting: 0, commission: 'EGP 50 per item', creators: 41, sales: '96000.00', orders: 410, lastChange: 'Since 12 Oct 2026' },
];
function Campaigns() {
const words = useCampaignColumnsCopy();
return <DataTable label="Campaigns" columns={campaignColumns('en', words, { decimals: 'auto' })} rows={ROWS} rowKey={(r) => r.id} onRowClick={() => {}} />;
}Wrapping cells
campaignColumns(language, copy, money, { wrap: true }) lets the dates, commission, sales and last change wrap, as on the v3 mock's Affiliate programs page: "1 Nov 2026 → 31 Jan 2027" takes two lines in a narrower column and the rows grow to about 79px. Without it every cell stays on one line.
Code
import { DataTable, campaignColumns, useCampaignColumnsCopy, type CampaignRow } from '@ergasti/bricks';
const ROWS: CampaignRow[] = [
{ id: 'glow', brand: { id: 'glow', name: 'Glow Lab', color: '#C7325C' }, campaign: { name: 'Winter glow 2026', from: '1 Nov 2026', to: '31 Jan 2027' }, status: 'active', waiting: 2, commission: '10% of sale', creators: 86, sales: '412300.00', orders: 1284, lastChange: 'Since 1 Oct 2026' },
{ id: 'nile', brand: { id: 'nile', name: 'Nile Threads', color: '#2C45A6' }, campaign: { name: 'Nile autumn', from: '12 Oct 2026', to: '31 Dec 2026' }, status: 'active', waiting: 0, commission: 'EGP 50 per item', creators: 41, sales: '96000.00', orders: 410, lastChange: 'Since 12 Oct 2026' },
];
function CampaignsWrapping() {
const words = useCampaignColumnsCopy();
return <DataTable label="Campaigns" columns={campaignColumns('en', words, { decimals: 'auto' }, { wrap: true })} rows={ROWS} rowKey={(r) => r.id} onRowClick={() => {}} />;
}CHALLENGE_STATUSES
constant
The Challenges screen's tabs, in the mock's order.
const CHALLENGE_STATUSES: readonly ["live", "upcoming", "settling", "ended", "needs_review"]Source: src/pr/challenges/challengeColumns.tsx (line 89)
Challenges table with status chips
The chips filter by status with counts; challengeColumns is the matching column preset (challenge, brand, status, dates, creators, sales, commission, waiting).
Code
import { useState } from 'react';
import { ChallengeStatusFilter, DataTable, challengeColumns } from '@ergasti/bricks';
import { challengeRows } from './pr';
function Challenges() {
const [chip, setChip] = useState('live');
const rows = challengeRows.filter((c) => chip === 'all' || c.status === chip);
return (
<div style={{ display: 'grid', gap: 14 }}>
<ChallengeStatusFilter value={chip} onChange={setChip} counts={{ all: 4, live: 2, upcoming: 1, settling: 1, ended: 0, needs_review: 2 }} />
<DataTable label="Challenges" columns={challengeColumns('en', { onOpen: () => {} })} rows={rows} rowKey={(r) => r.id} />
</div>
);
}Your own statuses, no "All"
statuses sets which chips show and in what order (default CHALLENGE_STATUSES); withAll={false} drops the "All" chip. With no counts, chips show no numbers.
Code
import { useState } from 'react';
import { ChallengeStatusFilter } from '@ergasti/bricks';
function Subset() {
const [chip, setChip] = useState('needs_review');
return <ChallengeStatusFilter value={chip} onChange={setChip} statuses={['needs_review', 'upcoming', 'live']} withAll={false} />;
}challengeColumns
function
The challengeColumns DataTable column preset. money: how its money cells are shown (slot challengeColumns.figures, over the provider).
function challengeColumns(language: Lang, on?: { onOpen?: (row: ChallengeRow) => void; }, money?: MoneyDisplay | undefined): DataColumn<ChallengeRow>[]Prop
Type
Source: src/pr/challenges/challengeColumns.tsx (line 47)
Challenges table with status chips
The chips filter by status with counts; challengeColumns is the matching column preset (challenge, brand, status, dates, creators, sales, commission, waiting).
Code
import { useState } from 'react';
import { ChallengeStatusFilter, DataTable, challengeColumns } from '@ergasti/bricks';
import { challengeRows } from './pr';
function Challenges() {
const [chip, setChip] = useState('live');
const rows = challengeRows.filter((c) => chip === 'all' || c.status === chip);
return (
<div style={{ display: 'grid', gap: 14 }}>
<ChallengeStatusFilter value={chip} onChange={setChip} counts={{ all: 4, live: 2, upcoming: 1, settling: 1, ended: 0, needs_review: 2 }} />
<DataTable label="Challenges" columns={challengeColumns('en', { onOpen: () => {} })} rows={rows} rowKey={(r) => r.id} />
</div>
);
}Your own statuses, no "All"
statuses sets which chips show and in what order (default CHALLENGE_STATUSES); withAll={false} drops the "All" chip. With no counts, chips show no numbers.
Code
import { useState } from 'react';
import { ChallengeStatusFilter } from '@ergasti/bricks';
function Subset() {
const [chip, setChip] = useState('needs_review');
return <ChallengeStatusFilter value={chip} onChange={setChip} statuses={['needs_review', 'upcoming', 'live']} withAll={false} />;
}challengeIssues
function
The builder's checks on a draft, field by field, the way the mock's summary checks it before launch: a brand, a name and both dates (the end after the start); a whole number of winners (and of goal orders); money above 0 for a goal in sales, the boost's cap and the cash per winner; a gift when the reward is a gift. Only the fields the draft's type and reward use are checked (no reward step for a boost; no audience step for a TRNDR-wide challenge). Pass a partial draft to check one step. The app's server checks again.
function challengeIssues(draft: Partial<ChallengeDraft>): Partial<Record<keyof ChallengeDraft, ChallengeIssue>>Prop
Type
Source: src/pr/challenges/challengeDraft.ts (line 95)
The challenge builder
A Stepper, one BuilderStepCard per step around that step's fields, and the flat ChallengeSummary in a sticky side column (PageGrid split="8-4" stickyAside). One ChallengeDraft state feeds every step; challengeIssues(draft) finds what is missing, and the summary turns it into red lines that go back to the step. Try Continue with an empty name.
Code
import { useState } from 'react';
import { BuilderStepCard, ChallengeAudienceFields, ChallengeBasicsFields, ChallengeRewardFields, ChallengeSummary, PageGrid, Stepper, challengeIssues, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
import { brands } from './pr';
const BRANDS = [brands.glow, brands.nile, { ...brands.kemet, paused: true }];
const GIFTS = [{ id: 'serum', name: 'Glow serum', cost: '300.00', left: 18 }];
const STEPS = ['Basics', 'Type & goal', 'Who can join', 'Reward'];
function Builder() {
const [step, setStep] = useState(1);
const [draft, setDraft] = useState<ChallengeDraft>(defaultChallengeDraft('glow'));
const brand = BRANDS.find((b) => b.id === draft.brand);
const issues = challengeIssues(draft);
const fields = [
<ChallengeBasicsFields key="1" value={draft} onChange={setDraft} brands={BRANDS} validate={step > 1 || !!draft.name} />,
<ChallengeRewardFields key="2" value={draft} onChange={setDraft} validate />,
<ChallengeAudienceFields key="3" value={draft} onChange={setDraft} brandName={brand?.name ?? ''} trndrWide={draft.brand === 'all'} />,
<ChallengeRewardFields key="4" part="payout" value={draft} onChange={setDraft} gifts={GIFTS} brandName={brand?.name ?? ''} validate />,
][step - 1];
return (
<PageGrid split="8-4" align="start" stickyAside>
<div>
<Stepper steps={STEPS} current={step - 1} onStep={(i) => setStep(i + 1)} />
<BuilderStepCard title={STEPS[step - 1]} step={step} onBack={() => setStep(step - 1)} onContinue={() => setStep(step + 1)}>{fields}</BuilderStepCard>
</div>
<ChallengeSummary layout="flat" flatDensity="mock" name={draft.name} brand={brand ?? { id: 'all', name: 'All brands' }} payer={draft.brand === 'all' ? 'trndr' : 'brand'}
status="upcoming" dates={draft.starts && draft.ends ? `${draft.starts} → ${draft.ends}` : '—'} goal={`Top ${draft.winners} by ${draft.rankBy}`} eligibility={{ audience: draft.audience }}
rewards={[{ key: 'per', label: 'Reward', amount: '1000.00', figure: 'challenge_commission', hint: 'each', inlineHint: true }]} budget={{ hold: '10000.00', available: '43390.00' }}
warnings={Object.keys(issues).map((field) => ({ id: field, text: `Fix ${field}`, tone: 'bad' as const, step: field === 'name' || field === 'starts' || field === 'ends' ? 'basics' : 'reward' }))}
steps={{ basics: '1', goal: '2', join: '3', reward: '4' }} onEditStep={(s) => setStep(Number(s))} onPrimary={() => {}} onSaveDraft={() => {}} money={{ decimals: 'auto' }} />
</PageGrid>
);
}Type & goal
ChallengeRewardFields (part="goal", the default) asks Leaderboard (rank by, winners), Target (goal, what it counts, the most winners) or Commission boost (×1.5 / 2 / 3, the cap on the extra). Pick each card.
Code
import { useState } from 'react';
import { BuilderStepCard, ChallengeRewardFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
function TypeAndGoal() {
const [draft, setDraft] = useState<ChallengeDraft>({ ...defaultChallengeDraft('glow'), type: 'boost' });
return <BuilderStepCard title="Type & goal" step={2} onBack={() => {}} onContinue={() => {}}><ChallengeRewardFields value={draft} onChange={setDraft} validate /></BuilderStepCard>;
}Reward
part="payout": Cash per winner, or a Gift from the brand's confirmed stock (the ChallengeGiftPicker), then when winners are paid (an open decision until someone decides it; pass paidWhen once it is). A boost has no reward step: the boost is the reward.
Code
import { useState } from 'react';
import { BuilderStepCard, ChallengeRewardFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
const GIFTS = [{ id: 'serum', name: 'Glow serum', cost: '300.00', left: 18 }];
function Reward() {
const [draft, setDraft] = useState<ChallengeDraft>(defaultChallengeDraft('glow'));
return <BuilderStepCard title="Reward" step={4} onBack={() => {}}><ChallengeRewardFields part="payout" value={draft} onChange={setDraft} gifts={GIFTS} brandName="Glow Lab" money={{ decimals: 'auto' }} /></BuilderStepCard>;
}Who can join, and in Arabic
Public or the brand's affiliates only; a TRNDR-wide challenge (trndrWide) has no choice, just the sentence.
Code
import { useState } from 'react';
import { BuilderStepCard, ChallengeAudienceFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
function WhoCanJoinArabic() {
const [draft, setDraft] = useState<ChallengeDraft>(defaultChallengeDraft('glow'));
return <BuilderStepCard title="مين يقدر يشترك" step={3} onBack={() => {}} onContinue={() => {}}><ChallengeAudienceFields value={draft} onChange={setDraft} brandName="Glow Lab" /></BuilderStepCard>;
}challengeRequestColumns
function
Challenges › Brand requests as a DataTable column preset (the PR v3 mock's reqs table): the request (brand square, idea, "brand · reward"), what the brand wrote, the dates chip, the budget, when it was sent and its status ("Needs review"). on.onOpen makes the idea a button (the row also opens with DataTable onRowClick). money: how the budget is shown, over the provider's money and moneyFor['challengeRequestColumns.budget'] (the slot's default: cents only when non-zero, "EGP 10,000").
function challengeRequestColumns(language: Lang, on?: { onOpen?: (row: ChallengeRequestRow) => void; }, copy?: Partial<{ readonly request: string; readonly wrote: string; readonly dates: string; readonly budget: string; readonly sent: string; readonly status: string; readonly sub: (brand: string, reward: string) => string; }> | undefined, money?: MoneyDisplay | undefined): DataColumn<ChallengeRequestRow>[]Prop
Type
Source: src/pr/challenges/challengeRequestColumns.tsx (line 51)
Brand requests
Challenges › Brand requests: the brand's square with the idea and "brand · reward", what the brand wrote, the dates chip, the budget, when it was sent and "Needs review". challengeRequestColumns(language, { onOpen }) returns the columns; sort by idea or budget.
Code
import { DataTable, challengeRequestColumns, type ChallengeRequestRow } from '@ergasti/bricks';
const REQUESTS: ChallengeRequestRow[] = [
{ id: 'r1', idea: 'Sell 30 in December', brand: { id: 'nile', name: 'Nile Threads', color: '#2C45A6' }, reward: 'Cash', message: 'We want to push our winter line before New Year. Happy to go up to 15,000.', dates: '1–31 Dec', budget: '15000.00', sent: 'Today, 09:14' },
{ id: 'r2', idea: 'Lip oil bundle push', brand: { id: 'glow', name: 'Glow Lab', color: '#C7325C' }, reward: 'Gift', message: 'Push our lip oil bundle. We sent the gifts for it with the request.', dates: 'Dates set by TRNDR', budget: '6000.00', sent: '14 Nov, 10:02' },
];
function Requests() {
return <DataTable label="Brand requests" rows={REQUESTS} rowKey={(r) => r.id} columns={challengeRequestColumns('en', { onOpen: () => {} })} onRowClick={() => {}} sort={{ key: 'budget', dir: 'desc' }} onSort={() => {}} />;
}No requests, and loading
Pass the screen's own empty words; loading draws skeleton rows under the preset's headers.
Code
import { DataTable, challengeRequestColumns, type ChallengeRequestRow } from '@ergasti/bricks';
function EmptyAndLoading() {
return (
<div style={{ display: 'grid', gap: 16 }}>
<DataTable label="Brand requests" rows={[]} rowKey={(r: ChallengeRequestRow) => r.id} columns={challengeRequestColumns('en')} empty="No requests waiting" />
<DataTable label="Brand requests" rows={[]} rowKey={(r: ChallengeRequestRow) => r.id} columns={challengeRequestColumns('en')} loading loadingRows={2} />
</div>
);
}In Arabic
Headers and the status read in Arabic; what the brand wrote keeps its own direction.
Code
import { DataTable, challengeRequestColumns, type ChallengeRequestRow } from '@ergasti/bricks';
const REQUESTS: ChallengeRequestRow[] = [
{ id: 'r1', idea: 'Sell 30 in December', brand: { id: 'nile', name: 'Nile Threads', color: '#2C45A6' }, reward: 'Cash', message: 'We want to push our winter line before New Year. Happy to go up to 15,000.', dates: '1–31 Dec', budget: '15000.00', sent: 'Today, 09:14' },
{ id: 'r2', idea: 'Lip oil bundle push', brand: { id: 'glow', name: 'Glow Lab', color: '#C7325C' }, reward: 'Gift', message: 'Push our lip oil bundle. We sent the gifts for it with the request.', dates: 'Dates set by TRNDR', budget: '6000.00', sent: '14 Nov, 10:02' },
];
function Arabic() {
return (
<div dir="rtl">
<DataTable label="طلبات البراندات" rows={[{ ...REQUESTS[0], message: 'عايزين نزوّد مبيعات تشكيلة الشتا قبل راس السنة.' }, REQUESTS[1]]} rowKey={(r) => r.id} columns={challengeRequestColumns('ar')} language="ar" />
</div>
);
}Money display
The budget uses the challengeRequestColumns.budget money slot: cents only when not zero by default ("EGP 15,000"). Here the app sets BricksProvider moneyFor to always show two decimals; the preset's last argument (money) would win over it.
Code
import { BricksProvider, DataTable, challengeRequestColumns, type ChallengeRequestRow } from '@ergasti/bricks';
const REQUESTS: ChallengeRequestRow[] = [
{ id: 'r1', idea: 'Sell 30 in December', brand: { id: 'nile', name: 'Nile Threads', color: '#2C45A6' }, reward: 'Cash', message: 'We want to push our winter line before New Year. Happy to go up to 15,000.', dates: '1–31 Dec', budget: '15000.00', sent: 'Today, 09:14' },
{ id: 'r2', idea: 'Lip oil bundle push', brand: { id: 'glow', name: 'Glow Lab', color: '#C7325C' }, reward: 'Gift', message: 'Push our lip oil bundle. We sent the gifts for it with the request.', dates: 'Dates set by TRNDR', budget: '6000.00', sent: '14 Nov, 10:02' },
];
function MoneyDisplay() {
return (
<BricksProvider moneyFor={{ 'challengeRequestColumns.budget': { decimals: 2 } }}>
<DataTable label="Brand requests" rows={REQUESTS} rowKey={(r) => r.id} columns={challengeRequestColumns('en')} />
</BricksProvider>
);
}challengeTableColumns
function
The PR Challenges tab's Table view (the v3 mock's chall table, beside the Cards view) as a DataTable column preset: the challenge (its type's icon, the name, "Leaderboard · Public"), the brand over its dates, the goal chip, the reward chip (with "No gifts left" when a gift reward's brand has none), the time left (live: the days, raspberry at 3 or fewer; otherwise the status pill), how many joined and the budget held. Its rows are PrChallengeRow, the same data as PrChallengeCard (toPrChallengeCard), so one API mapper feeds both views. Sort keys name, brand, left, joined, held. money: how the budget is shown (slot prChallengeCard.figures, the card's, over the provider). challengeColumns (the v2 list) is unchanged.
function challengeTableColumns(language: Lang, options?: ChallengeTableColumnsOptions, money?: MoneyDisplay | undefined): DataColumn<PrChallengeRow>[]Prop
Type
Source: src/pr/challenges/challengeTableColumns.tsx (line 48)
Challenges table
The Challenges tab's Table view: the challenge with its type and audience, the brand over its dates, the goal and reward chips ("No gifts left" when a gift reward has no stock), the days left (raspberry at 3 or fewer; the status pill when not live), how many joined and the budget held.
Code
import { DataTable, challengeTableColumns, type PrChallengeRow } from '@ergasti/bricks';
import { brands } from './pr';
const rows: PrChallengeRow[] = [
{ id: 'winter', name: 'Winter top 10', type: 'leader', audience: 'public', brand: brands.glow, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: 'Top 10 by delivered sales', reward: 'EGP 1,000 each', joined: 64, held: '10000.00' },
{ id: 'sell20', name: 'Sell 20 in November', type: 'target', audience: 'brand', brand: brands.mira, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: '20 delivered orders', reward: 'Serum gift set', rewardKind: 'gift', noGiftsLeft: true, hit: 9, joined: 23, held: '7800.00' },
{ id: 'sprint', name: 'Weekend sprint', type: 'target', audience: 'brand', brand: brands.kemet, status: 'live', dates: '14–16 Nov', daysLeft: 1, timeProgress: 70, goal: 'EGP 5,000 delivered sales', reward: 'EGP 300 each', hit: 7, joined: 18, held: '6000.00' },
{ id: 'spring', name: 'Spring boost', type: 'boost', audience: 'public', brand: brands.nile, status: 'upcoming', dates: '1–14 Dec', goal: '×2 commission', reward: 'Up to EGP 5,000', joined: 0, held: '5000.00' },
];
function Table() {
return <DataTable label="Challenges" columns={challengeTableColumns('en', { onOpen: () => {} }, { decimals: 'auto' })} rows={rows} rowKey={(r) => r.id} onRowClick={() => {}} sort={{ key: 'held', dir: 'desc' }} onSort={() => {}} />;
}Cards or Table, one mapper
PrChallengeRow is PrChallengeCard's data plus an id, so the API's challenges are mapped once and feed both views; toPrChallengeCard(row) hands a row to the card.
Code
import { useState } from 'react';
import { DataTable, PrChallengeCard, Segmented, challengeTableColumns, toPrChallengeCard, type PrChallengeRow } from '@ergasti/bricks';
import { brands } from './pr';
const rows: PrChallengeRow[] = [
{ id: 'winter', name: 'Winter top 10', type: 'leader', audience: 'public', brand: brands.glow, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: 'Top 10 by delivered sales', reward: 'EGP 1,000 each', joined: 64, held: '10000.00' },
{ id: 'sell20', name: 'Sell 20 in November', type: 'target', audience: 'brand', brand: brands.mira, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: '20 delivered orders', reward: 'Serum gift set', rewardKind: 'gift', noGiftsLeft: true, hit: 9, joined: 23, held: '7800.00' },
{ id: 'sprint', name: 'Weekend sprint', type: 'target', audience: 'brand', brand: brands.kemet, status: 'live', dates: '14–16 Nov', daysLeft: 1, timeProgress: 70, goal: 'EGP 5,000 delivered sales', reward: 'EGP 300 each', hit: 7, joined: 18, held: '6000.00' },
{ id: 'spring', name: 'Spring boost', type: 'boost', audience: 'public', brand: brands.nile, status: 'upcoming', dates: '1–14 Dec', goal: '×2 commission', reward: 'Up to EGP 5,000', joined: 0, held: '5000.00' },
];
function CardsOrTable() {
const [view, setView] = useState<'cards' | 'table'>('table');
return (
<div style={{ display: 'grid', gap: 16 }}>
<Segmented size="sm" label="View" value={view} onChange={setView} options={[['cards', 'Cards'], ['table', 'Table']]} />
{view === 'table'
? <DataTable label="Challenges" columns={challengeTableColumns('en', {}, { decimals: 'auto' })} rows={rows} rowKey={(r) => r.id} onRowClick={() => {}} />
: <div className="kit-prc-grid">{rows.map((r) => <PrChallengeCard key={r.id} {...toPrChallengeCard(r)} onOpen={() => {}} money={{ decimals: 'auto' }} />)}</div>}
</div>
);
}In Arabic
Headers, type and audience and "يوم" read in Arabic; names stay in their own script.
Code
import { DataTable, challengeTableColumns, type PrChallengeRow } from '@ergasti/bricks';
import { brands } from './pr';
const rows: PrChallengeRow[] = [
{ id: 'winter', name: 'Winter top 10', type: 'leader', audience: 'public', brand: brands.glow, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: 'Top 10 by delivered sales', reward: 'EGP 1,000 each', joined: 64, held: '10000.00' },
{ id: 'sell20', name: 'Sell 20 in November', type: 'target', audience: 'brand', brand: brands.mira, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: '20 delivered orders', reward: 'Serum gift set', rewardKind: 'gift', noGiftsLeft: true, hit: 9, joined: 23, held: '7800.00' },
{ id: 'sprint', name: 'Weekend sprint', type: 'target', audience: 'brand', brand: brands.kemet, status: 'live', dates: '14–16 Nov', daysLeft: 1, timeProgress: 70, goal: 'EGP 5,000 delivered sales', reward: 'EGP 300 each', hit: 7, joined: 18, held: '6000.00' },
{ id: 'spring', name: 'Spring boost', type: 'boost', audience: 'public', brand: brands.nile, status: 'upcoming', dates: '1–14 Dec', goal: '×2 commission', reward: 'Up to EGP 5,000', joined: 0, held: '5000.00' },
];
function Arabic() {
return <DataTable label="التحديات" language="ar" columns={challengeTableColumns('ar', {}, { decimals: 'auto' })} rows={rows} rowKey={(r) => r.id} onRowClick={() => {}} />;
}COMMISSION_MAX_PERCENT
constant
The highest % the PR portal allows (the v3 mock's rule): 0.01 to 50, at most 2 decimals.
const COMMISSION_MAX_PERCENT: "50"Source: src/pr/programs/CommissionChangeForm.tsx (line 49)
Change the commission
% of sale or a fixed amount per item, the value (above 0 and up to COMMISSION_MAX_PERCENT, 50 %, with 2 decimals, said under the field; maxPercent changes the limit), the Tier bonus (an open decision), a message to the brand, then Save and notify once something changed. "What changes" beside it reads the same value: useCommissionText writes both rates with the provider's currency and commissionChangeError the same rule. Type 60, or ١٢٫٥ on an Arabic keyboard.
Code
import { useState } from 'react';
import { COMMISSION_MAX_PERCENT, Card, ChangePreview, CommissionChangeForm, PageGrid, commissionChangeError, useCommissionText, type CommissionChange } from '@ergasti/bricks';
const CURRENT = { kind: 'percent' as const, value: '10' };
function ChangeTheCommission() {
const [value, setValue] = useState<CommissionChange>({ ...CURRENT, note: '' });
const rate = useCommissionText();
const error = commissionChangeError(value.kind, value.value, 'en', { maxPercent: COMMISSION_MAX_PERCENT });
const changed = value.kind !== CURRENT.kind || Number(value.value) !== Number(CURRENT.value);
return (
<PageGrid split="7-5" align="start">
<CommissionChangeForm value={value} onChange={setValue} current={CURRENT} brandName="Glow Lab" onSave={() => {}} onCancel={() => {}} />
<Card title="What changes">
<ChangePreview from={rate(CURRENT.kind, CURRENT.value)} to={rate(value.kind, value.value)} changed={changed} error={error ?? undefined}
note="Applies to orders placed after you save. Orders already placed keep the old rate." />
</Card>
</PageGrid>
);
}Rates in words
commissionText(kind, value, language) for a string prop outside a component: "10% of sale", "EGP 50 per item", and in Arabic; currency takes another currency word (it defaults to EGP). In a component, useCommissionText() takes the BricksProvider's currency and words.
Code (not run)
import { commissionText } from '@ergasti/bricks';
function RatesInWords() {
return (
<ul>
<li>{commissionText('percent', '10', 'en')}</li>
<li>{commissionText('per_item', '50.00', 'en')}</li>
<li dir="rtl">{commissionText('percent', '12.5', 'ar')}</li>
<li dir="rtl">{commissionText('per_item', '50', 'ar')}</li>
</ul>
);
}In Arabic
Code
import { useState } from 'react';
import { CommissionChangeForm, type CommissionChange } from '@ergasti/bricks';
function Arabic() {
const [value, setValue] = useState<CommissionChange>({ kind: 'per_item', value: '50', note: '' });
return <div style={{ maxWidth: 600 }}><CommissionChangeForm value={value} onChange={setValue} current={{ kind: 'per_item', value: '50' }} brandName="Glow Lab" onSave={() => {}} onCancel={() => {}} /></div>;
}commissionChangeError
function
The PR portal's rule for a campaign commission, the one CommissionChangeForm checks: a % above 0 and up to 50 (or maxPercent), an amount per item above 0, both with at most 2 decimals. Null when valid; otherwise the message, in language (labels for other words). Use the same message in the "What changes" ChangePreview error.
function commissionChangeError(kind: CommissionKind, value: string, language: Lang, options4?: { maxPercent?: string; labels?: Partial<PrCommissionChangeCopy>; }): string | nulloptions4: { maxPercent?: string; labels?: Partial<PrCommissionChangeCopy>; }
Prop
Type
Source: src/pr/programs/CommissionChangeForm.tsx (line 56)
Change the commission
% of sale or a fixed amount per item, the value (above 0 and up to COMMISSION_MAX_PERCENT, 50 %, with 2 decimals, said under the field; maxPercent changes the limit), the Tier bonus (an open decision), a message to the brand, then Save and notify once something changed. "What changes" beside it reads the same value: useCommissionText writes both rates with the provider's currency and commissionChangeError the same rule. Type 60, or ١٢٫٥ on an Arabic keyboard.
Code
import { useState } from 'react';
import { COMMISSION_MAX_PERCENT, Card, ChangePreview, CommissionChangeForm, PageGrid, commissionChangeError, useCommissionText, type CommissionChange } from '@ergasti/bricks';
const CURRENT = { kind: 'percent' as const, value: '10' };
function ChangeTheCommission() {
const [value, setValue] = useState<CommissionChange>({ ...CURRENT, note: '' });
const rate = useCommissionText();
const error = commissionChangeError(value.kind, value.value, 'en', { maxPercent: COMMISSION_MAX_PERCENT });
const changed = value.kind !== CURRENT.kind || Number(value.value) !== Number(CURRENT.value);
return (
<PageGrid split="7-5" align="start">
<CommissionChangeForm value={value} onChange={setValue} current={CURRENT} brandName="Glow Lab" onSave={() => {}} onCancel={() => {}} />
<Card title="What changes">
<ChangePreview from={rate(CURRENT.kind, CURRENT.value)} to={rate(value.kind, value.value)} changed={changed} error={error ?? undefined}
note="Applies to orders placed after you save. Orders already placed keep the old rate." />
</Card>
</PageGrid>
);
}Rates in words
commissionText(kind, value, language) for a string prop outside a component: "10% of sale", "EGP 50 per item", and in Arabic; currency takes another currency word (it defaults to EGP). In a component, useCommissionText() takes the BricksProvider's currency and words.
Code (not run)
import { commissionText } from '@ergasti/bricks';
function RatesInWords() {
return (
<ul>
<li>{commissionText('percent', '10', 'en')}</li>
<li>{commissionText('per_item', '50.00', 'en')}</li>
<li dir="rtl">{commissionText('percent', '12.5', 'ar')}</li>
<li dir="rtl">{commissionText('per_item', '50', 'ar')}</li>
</ul>
);
}In Arabic
Code
import { useState } from 'react';
import { CommissionChangeForm, type CommissionChange } from '@ergasti/bricks';
function Arabic() {
const [value, setValue] = useState<CommissionChange>({ kind: 'per_item', value: '50', note: '' });
return <div style={{ maxWidth: 600 }}><CommissionChangeForm value={value} onChange={setValue} current={{ kind: 'per_item', value: '50' }} brandName="Glow Lab" onSave={() => {}} onCancel={() => {}} /></div>;
}commissionText
function
A commission rate in words, the way the PR portal writes it: "10% of sale" / "EGP 50 per item" ("10% من البيع" / "50 ج.م على القطعة"), trailing zeros dropped ("12.50" → "12.5"), Arabic-Indic digits read as digits. For a string prop (CampaignRow commission, NextCampaign commission, creatorRateLabel, a ChangePreview's from / to, a schedule dialog). In JSX, the blocks' <CommissionRate form="long"> draws the same words isolated. kind takes the blocks' CommissionKind, or 'pct' / 'egp'. A plain function, so it can't see the BricksProvider: in a component, use useCommissionText, which takes the provider's currency and labels.commissionInput words.
function commissionText(kind: CommissionKind | "pct" | "egp", value: string | number, language: Lang, options?: CommissionTextOptions): stringProp
Type
Source: src/pr/programs/commissionText.ts (line 41)
Change the commission
% of sale or a fixed amount per item, the value (above 0 and up to COMMISSION_MAX_PERCENT, 50 %, with 2 decimals, said under the field; maxPercent changes the limit), the Tier bonus (an open decision), a message to the brand, then Save and notify once something changed. "What changes" beside it reads the same value: useCommissionText writes both rates with the provider's currency and commissionChangeError the same rule. Type 60, or ١٢٫٥ on an Arabic keyboard.
Code
import { useState } from 'react';
import { COMMISSION_MAX_PERCENT, Card, ChangePreview, CommissionChangeForm, PageGrid, commissionChangeError, useCommissionText, type CommissionChange } from '@ergasti/bricks';
const CURRENT = { kind: 'percent' as const, value: '10' };
function ChangeTheCommission() {
const [value, setValue] = useState<CommissionChange>({ ...CURRENT, note: '' });
const rate = useCommissionText();
const error = commissionChangeError(value.kind, value.value, 'en', { maxPercent: COMMISSION_MAX_PERCENT });
const changed = value.kind !== CURRENT.kind || Number(value.value) !== Number(CURRENT.value);
return (
<PageGrid split="7-5" align="start">
<CommissionChangeForm value={value} onChange={setValue} current={CURRENT} brandName="Glow Lab" onSave={() => {}} onCancel={() => {}} />
<Card title="What changes">
<ChangePreview from={rate(CURRENT.kind, CURRENT.value)} to={rate(value.kind, value.value)} changed={changed} error={error ?? undefined}
note="Applies to orders placed after you save. Orders already placed keep the old rate." />
</Card>
</PageGrid>
);
}Rates in words
commissionText(kind, value, language) for a string prop outside a component: "10% of sale", "EGP 50 per item", and in Arabic; currency takes another currency word (it defaults to EGP). In a component, useCommissionText() takes the BricksProvider's currency and words.
Code (not run)
import { commissionText } from '@ergasti/bricks';
function RatesInWords() {
return (
<ul>
<li>{commissionText('percent', '10', 'en')}</li>
<li>{commissionText('per_item', '50.00', 'en')}</li>
<li dir="rtl">{commissionText('percent', '12.5', 'ar')}</li>
<li dir="rtl">{commissionText('per_item', '50', 'ar')}</li>
</ul>
);
}In Arabic
Code
import { useState } from 'react';
import { CommissionChangeForm, type CommissionChange } from '@ergasti/bricks';
function Arabic() {
const [value, setValue] = useState<CommissionChange>({ kind: 'per_item', value: '50', note: '' });
return <div style={{ maxWidth: 600 }}><CommissionChangeForm value={value} onChange={setValue} current={{ kind: 'per_item', value: '50' }} brandName="Glow Lab" onSave={() => {}} onCancel={() => {}} /></div>;
}creatorColumns
function
The creatorColumns DataTable column preset: creator (photo, name, "Customer · Since Nov 2026"), status, tier, TRNDR score, followers, brands, orders, all-time sales. A customer affiliate, a pending or a rejected creator has no tier and no score: a dash, read as "No tier" / "No score yet". money: how the sales cell is shown (slot creatorColumns.figures, over the provider). options: the name as a button, the reapply tooltip, sales that follow the figure (CreatorColumnsOptions); creatorColumns(language, { decimals: 'auto' }, { reapply: true, nullableSales: true }) draws what the deprecated prCreatorColumns did.
function creatorColumns(language: Lang, money: MoneyDisplay | undefined, options: CreatorColumnsOptions<PrNullableSalesCreatorRow> & { nullableSales: true; }): DataColumn<PrNullableSalesCreatorRow>[]Prop
Type
Source: src/pr/creators/creatorColumns.tsx (line 93)
Creators table
The PR Creators list as a column preset: status, tier, TRNDR score, followers, brands, orders, all-time sales; a customer affiliate shows "Customer · Since …" and no tier or score.
Code
import { DataTable, creatorColumns, type PrCreatorRow } from '@ergasti/bricks';
import { brands } from './pr';
const rows: PrCreatorRow[] = [
{ id: 1, seed: 2, name: 'Nour Hassan', status: 'active', tier: 'elite', score: 91, followers: { instagram: 120000, tiktok: 340000 }, brands: [brands.glow, brands.mira, brands.kemet, brands.nile], orders: 702, sales: '212000.00', joined: 'Jun 2026' },
{ id: 2, seed: 1, name: 'Sara Ali', status: 'active', tier: 'established', score: 62, followers: { instagram: 24000, tiktok: 61000 }, brands: [brands.nile], orders: 208, sales: '64300.00', joined: 'Aug 2026' },
{ id: 3, seed: 3, name: 'Reem Saeed', status: 'active', track: 'customer', tier: null, score: null, followers: {}, brands: [brands.glow], orders: 9, sales: '3100.00', joined: 'Nov 2026' },
{ id: 4, seed: 4, name: 'Jana Fouad', status: 'pending', track: 'customer', tier: null, score: null, followers: { instagram: 6000 }, brands: [brands.glow], orders: 7, sales: '2400.00', joined: '16 Nov 2026' },
];
function Creators() {
return <DataTable label="Creators" columns={creatorColumns('en', { decimals: 'auto' })} rows={rows} rowKey={(r) => r.id} onRowClick={() => {}} />;
}Options
creatorColumns(language, money, options): onOpen makes the name a button, reapply puts "Can reapply 1 Dec" on a rejected creator's pill (hover it), and nullableSales lets the figure decide (null or zero is a dash, sales with no delivered orders still show). Together they draw what the deprecated prCreatorColumns did.
Code
import { DataTable, creatorColumns, type PrCreatorRow, type PrNullableSalesCreatorRow } from '@ergasti/bricks';
import { brands } from './pr';
const rows: PrCreatorRow[] = [
{ id: 1, seed: 2, name: 'Nour Hassan', status: 'active', tier: 'elite', score: 91, followers: { instagram: 120000, tiktok: 340000 }, brands: [brands.glow, brands.mira, brands.kemet, brands.nile], orders: 702, sales: '212000.00', joined: 'Jun 2026' },
{ id: 2, seed: 1, name: 'Sara Ali', status: 'active', tier: 'established', score: 62, followers: { instagram: 24000, tiktok: 61000 }, brands: [brands.nile], orders: 208, sales: '64300.00', joined: 'Aug 2026' },
{ id: 3, seed: 3, name: 'Reem Saeed', status: 'active', track: 'customer', tier: null, score: null, followers: {}, brands: [brands.glow], orders: 9, sales: '3100.00', joined: 'Nov 2026' },
{ id: 4, seed: 4, name: 'Jana Fouad', status: 'pending', track: 'customer', tier: null, score: null, followers: { instagram: 6000 }, brands: [brands.glow], orders: 7, sales: '2400.00', joined: '16 Nov 2026' },
];
const withReapply: PrNullableSalesCreatorRow[] = [
...rows.slice(0, 2),
{ id: 5, seed: 5, name: 'Rana Fathy', status: 'rejected', tier: null, score: null, followers: { instagram: 3000 }, brands: [], orders: 0, sales: null, joined: 'Oct 2026', reapplyOn: '1 Dec' },
{ id: 6, seed: 0, name: 'Mona Tarek', status: 'active', tier: 'rising', score: 30, followers: { tiktok: 8000 }, brands: [brands.glow], orders: 0, sales: '450.00', joined: 'Nov 2026' },
];
function WithOptions() {
return <DataTable label="Creators" columns={creatorColumns('en', { decimals: 'auto' }, { onOpen: () => {}, reapply: true, nullableSales: true })} rows={withReapply} rowKey={(r) => r.id} onRowClick={() => {}} />;
}customerRateIssue
function
The customer-affiliates rule (the v3 mock's saveCRate / doSched): a customer rate is above 0 and below the brand's creator rate, in the same unit (both % of sale, or both an amount per item). Values are the field's text and the creator rate as decimal strings ("6", "6.5", "50.00"); Arabic-Indic digits count as digits; at most 2 decimals, no exponents. Compared exactly in hundredths (BigInt), never as floats. Null when the rate is fine.
function customerRateIssue(value: string, creatorRate: string): CustomerRateIssue | nullProp
Type
Source: src/pr/programs/customerRate.ts (line 15)
A brand's customer affiliates
The rate must stay above 0 and below the creator rate; the link can be copied, renewed or turned off.
Code
import { useState } from 'react';
import { CustomerAffiliatesCard } from '@ergasti/bricks';
function Customers() {
const [rate, setRate] = useState('6');
const [linkOn, setLinkOn] = useState(true);
return (
<CustomerAffiliatesCard brandName="Glow Lab" kind="percent" rate={rate} creatorRate="10" creatorRateLabel="10% of sale" customers={38} sales="41200.00"
link="trndr.app/join?c=GL5mt" linkOn={linkOn} onSaveRate={(v) => setRate(v.rate)} onNewLink={() => {}} onToggleLink={setLinkOn} />
);
}The same rule for your own form: customerRateIssue(value, creatorRate) is null, 'invalid' or 'not_below'
Code
import { customerRateIssue } from '@ergasti/bricks';
function Rule() {
return <p>{['6', '10', '0'].map((v) => `${v}: ${customerRateIssue(v, '10') ?? 'fine'}`).join(' · ')}</p>;
}defaultChallengeDraft
function
The mock's starting draft for a brand (defB(bid)): Leaderboard top 10 by sales, public, EGP 1,000 a winner.
function defaultChallengeDraft(brand?: string): ChallengeDraftProp
Type
Source: src/pr/challenges/challengeDraft.ts (line 70)
The challenge builder
A Stepper, one BuilderStepCard per step around that step's fields, and the flat ChallengeSummary in a sticky side column (PageGrid split="8-4" stickyAside). One ChallengeDraft state feeds every step; challengeIssues(draft) finds what is missing, and the summary turns it into red lines that go back to the step. Try Continue with an empty name.
Code
import { useState } from 'react';
import { BuilderStepCard, ChallengeAudienceFields, ChallengeBasicsFields, ChallengeRewardFields, ChallengeSummary, PageGrid, Stepper, challengeIssues, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
import { brands } from './pr';
const BRANDS = [brands.glow, brands.nile, { ...brands.kemet, paused: true }];
const GIFTS = [{ id: 'serum', name: 'Glow serum', cost: '300.00', left: 18 }];
const STEPS = ['Basics', 'Type & goal', 'Who can join', 'Reward'];
function Builder() {
const [step, setStep] = useState(1);
const [draft, setDraft] = useState<ChallengeDraft>(defaultChallengeDraft('glow'));
const brand = BRANDS.find((b) => b.id === draft.brand);
const issues = challengeIssues(draft);
const fields = [
<ChallengeBasicsFields key="1" value={draft} onChange={setDraft} brands={BRANDS} validate={step > 1 || !!draft.name} />,
<ChallengeRewardFields key="2" value={draft} onChange={setDraft} validate />,
<ChallengeAudienceFields key="3" value={draft} onChange={setDraft} brandName={brand?.name ?? ''} trndrWide={draft.brand === 'all'} />,
<ChallengeRewardFields key="4" part="payout" value={draft} onChange={setDraft} gifts={GIFTS} brandName={brand?.name ?? ''} validate />,
][step - 1];
return (
<PageGrid split="8-4" align="start" stickyAside>
<div>
<Stepper steps={STEPS} current={step - 1} onStep={(i) => setStep(i + 1)} />
<BuilderStepCard title={STEPS[step - 1]} step={step} onBack={() => setStep(step - 1)} onContinue={() => setStep(step + 1)}>{fields}</BuilderStepCard>
</div>
<ChallengeSummary layout="flat" flatDensity="mock" name={draft.name} brand={brand ?? { id: 'all', name: 'All brands' }} payer={draft.brand === 'all' ? 'trndr' : 'brand'}
status="upcoming" dates={draft.starts && draft.ends ? `${draft.starts} → ${draft.ends}` : '—'} goal={`Top ${draft.winners} by ${draft.rankBy}`} eligibility={{ audience: draft.audience }}
rewards={[{ key: 'per', label: 'Reward', amount: '1000.00', figure: 'challenge_commission', hint: 'each', inlineHint: true }]} budget={{ hold: '10000.00', available: '43390.00' }}
warnings={Object.keys(issues).map((field) => ({ id: field, text: `Fix ${field}`, tone: 'bad' as const, step: field === 'name' || field === 'starts' || field === 'ends' ? 'basics' : 'reward' }))}
steps={{ basics: '1', goal: '2', join: '3', reward: '4' }} onEditStep={(s) => setStep(Number(s))} onPrimary={() => {}} onSaveDraft={() => {}} money={{ decimals: 'auto' }} />
</PageGrid>
);
}Type & goal
ChallengeRewardFields (part="goal", the default) asks Leaderboard (rank by, winners), Target (goal, what it counts, the most winners) or Commission boost (×1.5 / 2 / 3, the cap on the extra). Pick each card.
Code
import { useState } from 'react';
import { BuilderStepCard, ChallengeRewardFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
function TypeAndGoal() {
const [draft, setDraft] = useState<ChallengeDraft>({ ...defaultChallengeDraft('glow'), type: 'boost' });
return <BuilderStepCard title="Type & goal" step={2} onBack={() => {}} onContinue={() => {}}><ChallengeRewardFields value={draft} onChange={setDraft} validate /></BuilderStepCard>;
}Reward
part="payout": Cash per winner, or a Gift from the brand's confirmed stock (the ChallengeGiftPicker), then when winners are paid (an open decision until someone decides it; pass paidWhen once it is). A boost has no reward step: the boost is the reward.
Code
import { useState } from 'react';
import { BuilderStepCard, ChallengeRewardFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
const GIFTS = [{ id: 'serum', name: 'Glow serum', cost: '300.00', left: 18 }];
function Reward() {
const [draft, setDraft] = useState<ChallengeDraft>(defaultChallengeDraft('glow'));
return <BuilderStepCard title="Reward" step={4} onBack={() => {}}><ChallengeRewardFields part="payout" value={draft} onChange={setDraft} gifts={GIFTS} brandName="Glow Lab" money={{ decimals: 'auto' }} /></BuilderStepCard>;
}Who can join, and in Arabic
Public or the brand's affiliates only; a TRNDR-wide challenge (trndrWide) has no choice, just the sentence.
Code
import { useState } from 'react';
import { BuilderStepCard, ChallengeAudienceFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
function WhoCanJoinArabic() {
const [draft, setDraft] = useState<ChallengeDraft>(defaultChallengeDraft('glow'));
return <BuilderStepCard title="مين يقدر يشترك" step={3} onBack={() => {}} onContinue={() => {}}><ChallengeAudienceFields value={draft} onChange={setDraft} brandName="Glow Lab" /></BuilderStepCard>;
}fileSize
function
"1.2 MB" / "340 KB", one decimal, Western digits.
function fileSize(bytes: number, language: Lang): stringProp
Type
Source: src/pr/ReceiptUpload.tsx (line 47)
Receipt upload
Four states: empty (a drop area and a button), uploading (with progress), uploaded (file name, size, View and Remove) and error. The component only reports the chosen File; you upload it and set the state.
Code
import { useState } from 'react';
import { ReceiptUpload, fileSize, type ReceiptState } from '@ergasti/bricks';
function Upload() {
const [state, setState] = useState<ReceiptState>('empty');
return (
<div style={{ maxWidth: 440 }}>
<ReceiptUpload state={state} progress={64} file={{ name: 'instapay-4471.pdf', size: 1_250_000, kind: 'pdf' }} onSelect={() => setState('uploaded')} onView={() => {}} onRemove={() => setState('empty')} />
<small>File size helper: {fileSize(1_250_000, 'en')}</small>
</div>
);
}All states side by side
Code
import { ReceiptUpload } from '@ergasti/bricks';
function States() {
return (
<div style={{ display: 'grid', gap: 14, maxWidth: 440 }}>
<ReceiptUpload state="uploading" progress={64} onSelect={() => {}} />
<ReceiptUpload state="error" error="The file is larger than 5 MB." onSelect={() => {}} />
<ReceiptUpload state="empty" disabled onSelect={() => {}} />
</div>
);
}A smaller limit
maxBytes sets the size check before upload (default 5 MB); here 1 MB, so most phone photos are refused with a message.
Code
import { useState } from 'react';
import { ReceiptUpload } from '@ergasti/bricks';
function SmallLimit() {
const [error, setError] = useState<string | undefined>();
return (
<div style={{ maxWidth: 440 }}>
<ReceiptUpload state={error ? 'error' : 'empty'} error={error} maxBytes={1024 * 1024} onSelect={(f) => setError(`Picked ${f.name}; your app uploads it now.`)} />
</div>
);
}FRAUD_SIGNALS
constant
The PR admin's fraud signals (its hold reasons and matcher arms). An app adds its own under statusTables.prFraud.
const FRAUD_SIGNALS: { readonly self_referral: { readonly tone: "bad"; readonly en: "Self-purchase"; readonly ar: "شراء ذاتي"; }; readonly cross_creator: { readonly tone: "warn"; readonly en: "Bought with another creator’s code"; readonly ar: "اشترى بكود صانع محتوى تاني"; }; readonly address_match: { readonly tone: "warn"; readonly en: "Shipped to a known address"; readonly ar: "اتشحن لعنوان معروف"; }; readonly identity_match: { readonly tone: "bad"; readonly en: "Buyer’s phone or email matches the creator"; readonly ar: "موبايل أو إيميل المشتري هو نفسه بتاع صانع المحتوى"; }; readonly fraud_ring: { readonly tone: …Source: src/pr/fraud/FraudSignalPill.tsx (line 18)
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>;
}fraudColumns
function
The fraud queue as a DataTable column preset (the shape of the presets in presets.tsx). money: how its money cells are shown (slot fraudCaseRow.figures, over the provider).
function fraudColumns(language: Lang, on?: { onOpen?: (row: FraudCase) => void; }, money?: MoneyDisplay | undefined): DataColumn<FraudCase>[]Prop
Type
Source: src/pr/fraud/FraudCaseRow.tsx (line 85)
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>;
}GIFT_SHIPMENT_FILTERS
constant
The Gift stock list's chips after "All", in the mock's order.
const GIFT_SHIPMENT_FILTERS: readonly GiftShipmentFilter[]Source: src/pr/gifts/GiftStatus.tsx (line 56)
A shipment's status, and "Problem reported" beside it while the brand disputes PR's count
Code
import { GiftStatusPills } from '@ergasti/bricks';
function Pills() {
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<GiftStatusPills state="expected" />
<GiftStatusPills state="arrived" />
<GiftStatusPills state="confirmed_diff" problem />
<GiftStatusPills state="confirmed" />
</div>
);
}The Gift stock list: status chips over giftShipmentColumns (reference, brand, for, units claimed and confirmed, status)
giftShipmentMatches filters by a chip; "Problem reported" matches any state with an open report.
Code
import { useState } from 'react';
import { DataTable, GiftStatusFilter, giftShipmentColumns, giftShipmentMatches, type GiftShipmentFilter, type GiftShipmentRow } from '@ergasti/bricks';
const glow = { id: 'glow', name: 'Glow Lab', color: '#C7325C' };
const rows: GiftShipmentRow[] = [
{ id: 'GS-0017', sent: '17 Nov', brand: glow, for: 'December glow', claimed: 40, state: 'expected' },
{ id: 'GS-0013', sent: '15 Nov', brand: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' }, for: 'Weekend sprint', claimed: 40, state: 'arrived' },
{ id: 'GS-0014', sent: '9 Nov', brand: glow, for: 'Lip oil bundle push', claimed: 60, confirmed: 54, state: 'confirmed_diff', problem: true },
{ id: 'GS-0009', sent: '28 Oct', brand: glow, for: 'Winter glow launch', claimed: 115, confirmed: 115, state: 'confirmed' },
];
function GiftStockList() {
const [chip, setChip] = useState<GiftShipmentFilter | 'all'>('all');
return (
<div style={{ display: 'grid', gap: 14 }}>
<GiftStatusFilter value={chip} onChange={setChip} />
<DataTable label="Gift shipments" columns={giftShipmentColumns('en')} rows={rows.filter((r) => giftShipmentMatches(chip, r))} rowKey={(r) => r.id} onRowClick={() => {}} />
</div>
);
}giftAnalyticsColumns
function
deprecated
Deprecated
Since 0.7.0: use giftBrandColumns with GiftBrandRow, the 0.4.0 gift family. Kept working; removed in 1.0.
The Gift analytics "By brand" table as a DataTable column preset: brand, stock used (bar and "58/100"), sent, delivered with the delivery rate, received vs claimed, and OK / Running low / Out of gifts.
function giftAnalyticsColumns(language: Lang, copy?: Partial<{ readonly reference: string; readonly brand: string; readonly for: string; readonly claimed: string; readonly confirmed: string; readonly status: string; readonly sentOn: (d: string) => string; readonly stockUsed: string; readonly sent: string; readonly delivered: string; readonly receivedVsClaimed: string; readonly state: string; readonly ofTotal: (used: string, total: string) => string; readonly claimsLabel: string; readonly byBrandLabel: string; readonly says: (b: string) => string; readonly saysVs: (b: string) => string; readonly product: string; readonly brandSays: string; readonly inFull: string; readonly good: string; readonly damaged: string; readonly missing: string; readonly extra: (n: string) => string; readonly allOk: (n: string) => string; readonly goodHint: string; readonly goodOf: (p: string) => string; readonly damagedOf: (p: string) => string; readonly check: (n: string, one: boolean) => string; readonly tickAll: string; readonly howTo: (b: string) => string; readonly boxes: string; readonly brandSaid: (b: string, n: string) => string; readonly confirm: string; readonly confirming: string; readonly boxesErr: string; readonly unitsErr: string; readonly difference: (good: string, claimed: string, b: string) => string; readonly matched: (good: string, b: string) => string; readonly problem: (b: string, d: string) => string; readonly keep: string; readonly recount: string; readonly cancelled: string; readonly shipments: string; readonly problems: (n: string, one: boolean) => string; }> | undefined): DataColumn<GiftBrandStockRow>[]Prop
Type
Source: src/pr/gifts/GiftClaims.tsx (line 160)
Gift stock claims
Deprecated since 0.7.0: use giftShipmentColumns (and giftBrandColumns for the table below); these presets keep working. Reference and sent date, brand, what it is for, units claimed, units confirmed (— until counted) and the status, with "Problem reported" beside it while the brand disputes the count.
Code
import { DataTable, giftClaimColumns } from '@ergasti/bricks';
import { giftClaims } from './pr';
function Claims() {
return <DataTable label="Gift stock" rows={giftClaims} rowKey={(r) => r.id} columns={giftClaimColumns('en', { onOpen: () => {} })} sort={{ key: 'brand', dir: 'asc' }} onSort={() => {}} />;
}Gift analytics by brand
giftAnalyticsColumns is deprecated since 0.7.0: use giftBrandColumns. Stock used as a bar and "used/total", sent, delivered with the delivery rate, received vs claimed, and OK / Running low / Out of gifts.
Code
import { DataTable, giftAnalyticsColumns } from '@ergasti/bricks';
import { giftStock } from './pr';
function ByBrand() {
return <DataTable label="By brand" rows={giftStock} rowKey={(r) => r.id} columns={giftAnalyticsColumns('en')} onRowClick={() => {}} />;
}giftBrandColumns
function
The giftBrandColumns DataTable column preset: Gift analytics' "By brand" table (brand, stock used bar with "58/100", sent, delivered with its rate under it, received vs claimed, the stock status pill). The status column's header is read, not shown, as the mock's. Pass onRowClick to the table to open the brand.
function giftBrandColumns(language: Lang, copy?: 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): DataColumn<GiftBrandRow>[]Prop
Type
Source: src/pr/ganalytics/GiftAnalytics.tsx (line 82)
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>
);
}giftClaimColumns
function
deprecated
Deprecated
Since 0.7.0: use giftShipmentColumns with GiftShipmentRow (open a row with the table's onRowClick), the 0.4.0 gift family. Kept working; removed in 1.0.
The Gift stock list as a DataTable column preset (the v3 mock's Gift stock table): reference with the sent date, brand, what it is for, units claimed, units confirmed (— until counted) and the status, with "Problem reported" beside it while a report is open. onOpen makes the reference a link to the claim.
function giftClaimColumns(language: Lang, on?: { onOpen?: (row: GiftClaimRow) => void; }, copy?: Partial<{ readonly reference: string; readonly brand: string; readonly for: string; readonly claimed: string; readonly confirmed: string; readonly status: string; readonly sentOn: (d: string) => string; readonly stockUsed: string; readonly sent: string; readonly delivered: string; readonly receivedVsClaimed: string; readonly state: string; readonly ofTotal: (used: string, total: string) => string; readonly claimsLabel: string; readonly byBrandLabel: string; readonly says: (b: string) => string; readonly saysVs: (b: string) => string; readonly product: string; readonly brandSays: string; readonly inFull: string; readonly good: string; readonly damaged: string; readonly missing: string; readonly extra: (n: string) => string; readonly allOk: (n: string) => string; readonly goodHint: string; readonly goodOf: (p: string) => string; readonly damagedOf: (p: string) => string; readonly check: (n: string, one: boolean) => string; readonly tickAll: string; readonly howTo: (b: string) => string; readonly boxes: string; readonly brandSaid: (b: string, n: string) => string; readonly confirm: string; readonly confirming: string; readonly boxesErr: string; readonly unitsErr: string; readonly difference: (good: string, claimed: string, b: string) => string; readonly matched: (good: string, b: string) => string; readonly problem: (b: string, d: string) => string; readonly keep: string; readonly recount: string; readonly cancelled: string; readonly shipments: string; readonly problems: (n: string, one: boolean) => string; }> | undefined): DataColumn<GiftClaimRow>[]Prop
Type
Source: src/pr/gifts/GiftClaims.tsx (line 111)
Gift stock claims
Deprecated since 0.7.0: use giftShipmentColumns (and giftBrandColumns for the table below); these presets keep working. Reference and sent date, brand, what it is for, units claimed, units confirmed (— until counted) and the status, with "Problem reported" beside it while the brand disputes the count.
Code
import { DataTable, giftClaimColumns } from '@ergasti/bricks';
import { giftClaims } from './pr';
function Claims() {
return <DataTable label="Gift stock" rows={giftClaims} rowKey={(r) => r.id} columns={giftClaimColumns('en', { onOpen: () => {} })} sort={{ key: 'brand', dir: 'asc' }} onSort={() => {}} />;
}Gift analytics by brand
giftAnalyticsColumns is deprecated since 0.7.0: use giftBrandColumns. Stock used as a bar and "used/total", sent, delivered with the delivery rate, received vs claimed, and OK / Running low / Out of gifts.
Code
import { DataTable, giftAnalyticsColumns } from '@ergasti/bricks';
import { giftStock } from './pr';
function ByBrand() {
return <DataTable label="By brand" rows={giftStock} rowKey={(r) => r.id} columns={giftAnalyticsColumns('en')} onRowClick={() => {}} />;
}giftShipmentColumns
function
The giftShipmentColumns DataTable column preset: Reference (+ "Sent 17 Nov"), Brand (square + name, sorts A–Z), For, Units claimed (sorts high to low), Units confirmed (a dash until counted), Status (GiftStatusPills).
function giftShipmentColumns(language: Lang, copy?: Partial<{ readonly reference: string; readonly brand: string; readonly for: string; readonly claimed: string; readonly confirmed: string; readonly status: string; readonly sent: (date: string) => string; readonly notYet: string; readonly search: string; readonly sortBrand: string; readonly sortUnits: string; readonly label: string; }> | undefined): DataColumn<GiftShipmentRow>[]Prop
Type
Source: src/pr/gifts/giftShipmentColumns.tsx (line 67)
A shipment's status, and "Problem reported" beside it while the brand disputes PR's count
Code
import { GiftStatusPills } from '@ergasti/bricks';
function Pills() {
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<GiftStatusPills state="expected" />
<GiftStatusPills state="arrived" />
<GiftStatusPills state="confirmed_diff" problem />
<GiftStatusPills state="confirmed" />
</div>
);
}The Gift stock list: status chips over giftShipmentColumns (reference, brand, for, units claimed and confirmed, status)
giftShipmentMatches filters by a chip; "Problem reported" matches any state with an open report.
Code
import { useState } from 'react';
import { DataTable, GiftStatusFilter, giftShipmentColumns, giftShipmentMatches, type GiftShipmentFilter, type GiftShipmentRow } from '@ergasti/bricks';
const glow = { id: 'glow', name: 'Glow Lab', color: '#C7325C' };
const rows: GiftShipmentRow[] = [
{ id: 'GS-0017', sent: '17 Nov', brand: glow, for: 'December glow', claimed: 40, state: 'expected' },
{ id: 'GS-0013', sent: '15 Nov', brand: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' }, for: 'Weekend sprint', claimed: 40, state: 'arrived' },
{ id: 'GS-0014', sent: '9 Nov', brand: glow, for: 'Lip oil bundle push', claimed: 60, confirmed: 54, state: 'confirmed_diff', problem: true },
{ id: 'GS-0009', sent: '28 Oct', brand: glow, for: 'Winter glow launch', claimed: 115, confirmed: 115, state: 'confirmed' },
];
function GiftStockList() {
const [chip, setChip] = useState<GiftShipmentFilter | 'all'>('all');
return (
<div style={{ display: 'grid', gap: 14 }}>
<GiftStatusFilter value={chip} onChange={setChip} />
<DataTable label="Gift shipments" columns={giftShipmentColumns('en')} rows={rows.filter((r) => giftShipmentMatches(chip, r))} rowKey={(r) => r.id} onRowClick={() => {}} />
</div>
);
}giftShipmentMatches
function
True when a shipment passes a filter (all, a state, or problem).
function giftShipmentMatches(filter: "all" | GiftShipmentFilter, row: { state: GiftShipmentState; problem?: boolean; }): booleanProp
Type
Source: src/pr/gifts/GiftStatus.tsx (line 59)
A shipment's status, and "Problem reported" beside it while the brand disputes PR's count
Code
import { GiftStatusPills } from '@ergasti/bricks';
function Pills() {
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<GiftStatusPills state="expected" />
<GiftStatusPills state="arrived" />
<GiftStatusPills state="confirmed_diff" problem />
<GiftStatusPills state="confirmed" />
</div>
);
}The Gift stock list: status chips over giftShipmentColumns (reference, brand, for, units claimed and confirmed, status)
giftShipmentMatches filters by a chip; "Problem reported" matches any state with an open report.
Code
import { useState } from 'react';
import { DataTable, GiftStatusFilter, giftShipmentColumns, giftShipmentMatches, type GiftShipmentFilter, type GiftShipmentRow } from '@ergasti/bricks';
const glow = { id: 'glow', name: 'Glow Lab', color: '#C7325C' };
const rows: GiftShipmentRow[] = [
{ id: 'GS-0017', sent: '17 Nov', brand: glow, for: 'December glow', claimed: 40, state: 'expected' },
{ id: 'GS-0013', sent: '15 Nov', brand: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' }, for: 'Weekend sprint', claimed: 40, state: 'arrived' },
{ id: 'GS-0014', sent: '9 Nov', brand: glow, for: 'Lip oil bundle push', claimed: 60, confirmed: 54, state: 'confirmed_diff', problem: true },
{ id: 'GS-0009', sent: '28 Oct', brand: glow, for: 'Winter glow launch', claimed: 115, confirmed: 115, state: 'confirmed' },
];
function GiftStockList() {
const [chip, setChip] = useState<GiftShipmentFilter | 'all'>('all');
return (
<div style={{ display: 'grid', gap: 14 }}>
<GiftStatusFilter value={chip} onChange={setChip} />
<DataTable label="Gift shipments" columns={giftShipmentColumns('en')} rows={rows.filter((r) => giftShipmentMatches(chip, r))} rowKey={(r) => r.id} onRowClick={() => {}} />
</div>
);
}giftStatusKey
function
The status key (TRNDR_PR_STATUSES, statusTables.pr) a shipment state is shown with: gift_expected…
function giftStatusKey(state: GiftShipmentState): stringProp
Type
Source: src/pr/gifts/GiftStatus.tsx (line 16)
A shipment's status, and "Problem reported" beside it while the brand disputes PR's count
Code
import { GiftStatusPills } from '@ergasti/bricks';
function Pills() {
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<GiftStatusPills state="expected" />
<GiftStatusPills state="arrived" />
<GiftStatusPills state="confirmed_diff" problem />
<GiftStatusPills state="confirmed" />
</div>
);
}The Gift stock list: status chips over giftShipmentColumns (reference, brand, for, units claimed and confirmed, status)
giftShipmentMatches filters by a chip; "Problem reported" matches any state with an open report.
Code
import { useState } from 'react';
import { DataTable, GiftStatusFilter, giftShipmentColumns, giftShipmentMatches, type GiftShipmentFilter, type GiftShipmentRow } from '@ergasti/bricks';
const glow = { id: 'glow', name: 'Glow Lab', color: '#C7325C' };
const rows: GiftShipmentRow[] = [
{ id: 'GS-0017', sent: '17 Nov', brand: glow, for: 'December glow', claimed: 40, state: 'expected' },
{ id: 'GS-0013', sent: '15 Nov', brand: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' }, for: 'Weekend sprint', claimed: 40, state: 'arrived' },
{ id: 'GS-0014', sent: '9 Nov', brand: glow, for: 'Lip oil bundle push', claimed: 60, confirmed: 54, state: 'confirmed_diff', problem: true },
{ id: 'GS-0009', sent: '28 Oct', brand: glow, for: 'Winter glow launch', claimed: 115, confirmed: 115, state: 'confirmed' },
];
function GiftStockList() {
const [chip, setChip] = useState<GiftShipmentFilter | 'all'>('all');
return (
<div style={{ display: 'grid', gap: 14 }}>
<GiftStatusFilter value={chip} onChange={setChip} />
<DataTable label="Gift shipments" columns={giftShipmentColumns('en')} rows={rows.filter((r) => giftShipmentMatches(chip, r))} rowKey={(r) => r.id} onRowClick={() => {}} />
</div>
);
}giftStockStatus
function
The mock's rule for a brand's gift stock: out when every confirmed unit is used, running low under 20 % left, OK otherwise (a brand with no confirmed stock is OK: there is nothing to run out of).
function giftStockStatus(used: number, total: number): GiftStockStatusProp
Type
Source: src/pr/ganalytics/GiftAnalytics.tsx (line 49)
isGiftCounting
function
True while PR still has to count what arrived (the mock's ct: the check table is shown).
function isGiftCounting(state: GiftShipmentState): booleanProp
Type
Source: src/pr/gifts/GiftStatus.tsx (line 19)
A shipment's status, and "Problem reported" beside it while the brand disputes PR's count
Code
import { GiftStatusPills } from '@ergasti/bricks';
function Pills() {
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<GiftStatusPills state="expected" />
<GiftStatusPills state="arrived" />
<GiftStatusPills state="confirmed_diff" problem />
<GiftStatusPills state="confirmed" />
</div>
);
}The Gift stock list: status chips over giftShipmentColumns (reference, brand, for, units claimed and confirmed, status)
giftShipmentMatches filters by a chip; "Problem reported" matches any state with an open report.
Code
import { useState } from 'react';
import { DataTable, GiftStatusFilter, giftShipmentColumns, giftShipmentMatches, type GiftShipmentFilter, type GiftShipmentRow } from '@ergasti/bricks';
const glow = { id: 'glow', name: 'Glow Lab', color: '#C7325C' };
const rows: GiftShipmentRow[] = [
{ id: 'GS-0017', sent: '17 Nov', brand: glow, for: 'December glow', claimed: 40, state: 'expected' },
{ id: 'GS-0013', sent: '15 Nov', brand: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' }, for: 'Weekend sprint', claimed: 40, state: 'arrived' },
{ id: 'GS-0014', sent: '9 Nov', brand: glow, for: 'Lip oil bundle push', claimed: 60, confirmed: 54, state: 'confirmed_diff', problem: true },
{ id: 'GS-0009', sent: '28 Oct', brand: glow, for: 'Winter glow launch', claimed: 115, confirmed: 115, state: 'confirmed' },
];
function GiftStockList() {
const [chip, setChip] = useState<GiftShipmentFilter | 'all'>('all');
return (
<div style={{ display: 'grid', gap: 14 }}>
<GiftStatusFilter value={chip} onChange={setChip} />
<DataTable label="Gift shipments" columns={giftShipmentColumns('en')} rows={rows.filter((r) => giftShipmentMatches(chip, r))} rowKey={(r) => r.id} onRowClick={() => {}} />
</div>
);
}isPrStatus
function
One of the PR portal's own status keys (the TRNDR preset's statusTables.pr).
function isPrStatus(value: string): booleanProp
Type
Source: src/pr/PrStatus.tsx (line 12)
joinRequestColumns
function
The join-requests table's columns for DataTable: creator, followers, the brand they want, source, how long they have waited and the approve and reject actions. on supplies the handlers and an optional per-row busy state.
function joinRequestColumns(language: Lang, on: { onApprove: (row: JoinRequestRow) => void; onReject: (row: JoinRequestRow) => void; onOpen?: (row: JoinRequestRow) => void; busy?: (row: JoinRequestRow) => boolean; }, copy?: Partial<PrColumnsCopy> | undefined): DataColumn<JoinRequestRow>[]Prop
Type
Source: src/pr/presets.tsx (line 77)
Join requests table
The column preset gives the creator, followers, brand, source, waiting time and the approve and reject buttons, in the page's language; you give the handlers and the rows. The preset's sort keys are named after the row fields.
Code
import { useState } from 'react';
import { DataTable, joinRequestColumns } from '@ergasti/bricks';
import { joinRequests } from './pr';
function JoinRequests() {
const [selected, setSelected] = useState<ReadonlySet<string | number>>(new Set([1, 2]));
return (
<DataTable
label="Join requests" rows={joinRequests} rowKey={(r) => r.id}
columns={joinRequestColumns('en', { onApprove: () => {}, onReject: () => {}, onOpen: () => {} })}
selection={{ selected, onChange: setSelected, rowLabel: (r) => r.creator.name }}
sort={{ key: 'waiting', dir: 'desc' }} onSort={() => {}}
/>
);
}The other presets
Brands, payouts (with a receipt button), wallet top-ups (with a confirm button), announcements and the audit log: each is xColumns(language, handlers) returning DataColumn<Row>[] for DataTable.
Code
import { DataTable, auditColumns, brandColumns, messageColumns, payoutColumns, topUpColumns } from '@ergasti/bricks';
import { auditEntries, brandRows, messages, payouts, topUps } from './pr';
function MorePresets() {
return (
<div style={{ display: 'grid', gap: 24 }}>
<DataTable label="Brands" rows={brandRows} rowKey={(r) => r.id} columns={brandColumns('en')} onRowClick={() => {}} />
<DataTable label="Payouts" rows={payouts} rowKey={(r) => r.id} columns={payoutColumns('en', { onReceipt: () => {} })} />
<DataTable label="Top-ups" rows={topUps} rowKey={(r) => r.id} columns={topUpColumns('en', { onConfirm: () => {} })} />
<DataTable label="Messages" rows={messages} rowKey={(r) => r.id} columns={messageColumns('en')} onRowClick={() => {}} />
<DataTable label="Audit log" rows={auditEntries} rowKey={(r) => r.id} columns={auditColumns('en')} />
</div>
);
}messageColumns
function
The announcements table's columns for DataTable: subject, sender, audience, creators reached, open rate and sent time.
function messageColumns(language: Lang, copy?: Partial<PrColumnsCopy> | undefined): DataColumn<MessageRow>[]Prop
Type
Source: src/pr/presets.tsx (line 213)
Join requests table
The column preset gives the creator, followers, brand, source, waiting time and the approve and reject buttons, in the page's language; you give the handlers and the rows. The preset's sort keys are named after the row fields.
Code
import { useState } from 'react';
import { DataTable, joinRequestColumns } from '@ergasti/bricks';
import { joinRequests } from './pr';
function JoinRequests() {
const [selected, setSelected] = useState<ReadonlySet<string | number>>(new Set([1, 2]));
return (
<DataTable
label="Join requests" rows={joinRequests} rowKey={(r) => r.id}
columns={joinRequestColumns('en', { onApprove: () => {}, onReject: () => {}, onOpen: () => {} })}
selection={{ selected, onChange: setSelected, rowLabel: (r) => r.creator.name }}
sort={{ key: 'waiting', dir: 'desc' }} onSort={() => {}}
/>
);
}The other presets
Brands, payouts (with a receipt button), wallet top-ups (with a confirm button), announcements and the audit log: each is xColumns(language, handlers) returning DataColumn<Row>[] for DataTable.
Code
import { DataTable, auditColumns, brandColumns, messageColumns, payoutColumns, topUpColumns } from '@ergasti/bricks';
import { auditEntries, brandRows, messages, payouts, topUps } from './pr';
function MorePresets() {
return (
<div style={{ display: 'grid', gap: 24 }}>
<DataTable label="Brands" rows={brandRows} rowKey={(r) => r.id} columns={brandColumns('en')} onRowClick={() => {}} />
<DataTable label="Payouts" rows={payouts} rowKey={(r) => r.id} columns={payoutColumns('en', { onReceipt: () => {} })} />
<DataTable label="Top-ups" rows={topUps} rowKey={(r) => r.id} columns={topUpColumns('en', { onConfirm: () => {} })} />
<DataTable label="Messages" rows={messages} rowKey={(r) => r.id} columns={messageColumns('en')} onRowClick={() => {}} />
<DataTable label="Audit log" rows={auditEntries} rowKey={(r) => r.id} columns={auditColumns('en')} />
</div>
);
}messageNotOpened
function
Creators who did not open a message: the share not opened of its creators, rounded (the mock's notOpened).
function messageNotOpened(creators: number, openPercent: number): numberProp
Type
Source: src/pr/messages/MessageDrawer.tsx (line 36)
A sent message
Open a row of the Messages history: the subject and who sent it when, the message on soft grey, Creators and Opened, From / To / Not opened, and "Send another to the same people", which hands the message back so you can open your composer with the same sender and audience. "Not opened" defaults to messageNotOpened(creators, openPercent) (the creators who have not opened it, rounded); pass notOpened for your server's own figure.
Code
import { Button, MessageDrawer, type MessageRow } from '@ergasti/bricks';
import { useState } from 'react';
import { messages } from './pr';
function OpenAMessage() {
const [open, setOpen] = useState<MessageRow | null>(null);
const [again, setAgain] = useState<string | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
{messages.slice(0, 3).map((m) => <Button key={m.id} size="sm" onClick={() => setOpen(m)}>{m.subject}</Button>)}
<small>{again ? `Compose again to: ${again}` : 'Pick a message'}</small>
<MessageDrawer open={open !== null} message={open} onClose={() => setOpen(null)} onSendAnother={(m) => { setOpen(null); setAgain(m.subject); }} />
</div>
);
}Arabic
Code
import { Button, MessageDrawer } from '@ergasti/bricks';
import { useState } from 'react';
import { messages } from './pr';
function Arabic() {
const [open, setOpen] = useState(false);
return (
<>
<Button size="sm" onClick={() => setOpen(true)}>افتح الرسالة</Button>
<MessageDrawer open={open} message={messages[0]} onClose={() => setOpen(false)} onSendAnother={() => setOpen(false)} language="ar" />
</>
);
}newCreatorColumns
function
The PR Approvals › New creators table as a DataTable column preset (the PR v3 mock's new tab): the creator (photo, name, and "Customer asking to become a creator" for a customer affiliate), their followers, when they signed up, and Reject / Approve (text buttons whose names say who). Sort keys name, followers, signed.
function newCreatorColumns(language: Lang, on: NewCreatorColumnsOptions): DataColumn<PrNewCreatorRow>[]Prop
Type
Source: src/pr/creators/newCreatorColumns.tsx (line 51)
New creators
Approvals › New creators as a column preset: the creator ("Customer asking to become a creator" for a customer affiliate), followers, when they signed up, and Reject / Approve named for the creator. Deciding takes the row out here.
Code
import { useState } from 'react';
import { DataTable, newCreatorColumns, type PrNewCreatorRow } from '@ergasti/bricks';
const rows: PrNewCreatorRow[] = [
{ id: 1, seed: 2, name: 'Dina Samy', followers: { instagram: 41000, tiktok: 12000 }, signedUp: 'Today' },
{ id: 2, seed: 3, name: 'Karim Fawzy', customer: true, followers: { tiktok: 9000 }, signedUp: '15 Nov' },
{ id: 3, seed: 4, name: 'Ziad Hany', followers: { youtube: 22000 }, signedUp: '14 Nov' },
];
function NewCreators() {
const [left, setLeft] = useState(rows);
const decide = (row: PrNewCreatorRow) => setLeft((now) => now.filter((r) => r.id !== row.id));
return <DataTable label="New creators" columns={newCreatorColumns('en', { onApprove: decide, onReject: decide, onOpen: () => {} })} rows={left} rowKey={(r) => r.id} empty="No new creators" />;
}In Arabic
Code
import { DataTable, newCreatorColumns, type PrNewCreatorRow } from '@ergasti/bricks';
const rows: PrNewCreatorRow[] = [
{ id: 1, seed: 2, name: 'Dina Samy', followers: { instagram: 41000, tiktok: 12000 }, signedUp: 'Today' },
{ id: 2, seed: 3, name: 'Karim Fawzy', customer: true, followers: { tiktok: 9000 }, signedUp: '15 Nov' },
{ id: 3, seed: 4, name: 'Ziad Hany', followers: { youtube: 22000 }, signedUp: '14 Nov' },
];
function Arabic() {
return <DataTable label="صنّاع محتوى جداد" language="ar" columns={newCreatorColumns('ar', { onApprove: () => {}, onReject: () => {} })} rows={rows} rowKey={(r) => r.id} />;
}parseBrandFee
function
A fee as typed ("7.5", "7.50", Arabic-Indic digits and the Arabic decimal mark "٧٫٥") as a 2-dp percent string ("7.50"), or null when it is not 0–50 with up to two decimals. Exact: parsed in hundredths, never as a float.
function parseBrandFee(text: string): string | nullProp
Type
Source: src/pr/brand/BrandFeeDialog.tsx (line 45)
Change PR owner
The select starts on the current owner and marks you; saving the same person says so instead of calling onSave. value is null for a brand nobody owns yet (or an id no longer in owners): the select then starts on "Choose the new owner". Controlled by open; the choice resets each time it opens.
Code
import { Button, ChangeOwnerDialog } from '@ergasti/bricks';
import { useState } from 'react';
const PRS = [{ id: 'mona', name: 'Mona Adel' }, { id: 'farida', name: 'Farida Nabil' }, { id: 'ahmed', name: 'Ahmed Samy' }];
function ChangeOwner() {
const [open, setOpen] = useState(false);
const [owner, setOwner] = useState<string | number | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Change</Button>
<small>Owner: {PRS.find((p) => p.id === owner)?.name ?? 'nobody yet'}</small>
<ChangeOwnerDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" owners={PRS} value={owner} meId="mona" onSave={(id) => { setOwner(id); setOpen(false); }} />
</div>
);
}Adjust wallet
An amount that is not 0 with up to two decimals (a minus sign takes money out) and a reason. The field asks for a text keyboard, so a phone shows the minus key. The amount is parsed in cents by parseWalletAdjustment (exported for your own checks: "-390.1" gives "-390.10"; 0, "1.005" and "+-5" give null), so onSave gets an exact 2-dp string; with available the dialog shows what the wallet holds after it. Try 0, 1.005 or −390.10.
Code
import { AdjustWalletDialog, Button, type WalletAdjustment } from '@ergasti/bricks';
import { useState } from 'react';
function AdjustWallet() {
const [open, setOpen] = useState(false);
const [last, setLast] = useState<WalletAdjustment | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Adjust wallet</Button>
<small>{last ? `Saved ${last.amount}: ${last.reason}` : 'Nothing saved yet'}</small>
<AdjustWalletDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" available="43390.00" money={{ decimals: 'auto' }} onSave={(a) => { setLast(a); setOpen(false); }} />
</div>
);
}TRNDR fee
0 to BRAND_FEE_MAX (50) % with up to two decimals, checked by parseBrandFee ("7.5" gives "7.50", "50.01" gives null). "Use default (5%)" shows while the brand has its own fee, and saving an empty field uses the default too; without onUseDefault an empty field is an error. A failed save shows error; busy locks the buttons.
Code
import { BrandFeeDialog, Button } from '@ergasti/bricks';
import { useState } from 'react';
function Fee() {
const [open, setOpen] = useState(false);
const [fee, setFee] = useState<string | null>('7.5');
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Change fee</Button>
<small>Fee: {fee === null ? '5% (default)' : `${fee}%`}</small>
<BrandFeeDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" value={fee} defaultFee="5" onSave={(v) => { setFee(v); setOpen(false); }} onUseDefault={() => { setFee(null); setOpen(false); }} />
</div>
);
}Arabic
Code
import { AdjustWalletDialog, Button } from '@ergasti/bricks';
import { useState } from 'react';
function Arabic() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>عدّل المحفظة</Button>
<AdjustWalletDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" available="43390.00" onSave={() => setOpen(false)} language="ar" />
</>
);
}parseWalletAdjustment
function
An adjustment as typed ("500", "-120.5", "+75", "−20", Arabic-Indic digits and the Arabic decimal mark) as a signed 2-dp money string, or null when it is not a plain amount with up to two decimals, or is 0. Exact: parsed in whole cents, never as a float.
function parseWalletAdjustment(text: string): string | nullProp
Type
Source: src/pr/brand/AdjustWalletDialog.tsx (line 48)
Change PR owner
The select starts on the current owner and marks you; saving the same person says so instead of calling onSave. value is null for a brand nobody owns yet (or an id no longer in owners): the select then starts on "Choose the new owner". Controlled by open; the choice resets each time it opens.
Code
import { Button, ChangeOwnerDialog } from '@ergasti/bricks';
import { useState } from 'react';
const PRS = [{ id: 'mona', name: 'Mona Adel' }, { id: 'farida', name: 'Farida Nabil' }, { id: 'ahmed', name: 'Ahmed Samy' }];
function ChangeOwner() {
const [open, setOpen] = useState(false);
const [owner, setOwner] = useState<string | number | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Change</Button>
<small>Owner: {PRS.find((p) => p.id === owner)?.name ?? 'nobody yet'}</small>
<ChangeOwnerDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" owners={PRS} value={owner} meId="mona" onSave={(id) => { setOwner(id); setOpen(false); }} />
</div>
);
}Adjust wallet
An amount that is not 0 with up to two decimals (a minus sign takes money out) and a reason. The field asks for a text keyboard, so a phone shows the minus key. The amount is parsed in cents by parseWalletAdjustment (exported for your own checks: "-390.1" gives "-390.10"; 0, "1.005" and "+-5" give null), so onSave gets an exact 2-dp string; with available the dialog shows what the wallet holds after it. Try 0, 1.005 or −390.10.
Code
import { AdjustWalletDialog, Button, type WalletAdjustment } from '@ergasti/bricks';
import { useState } from 'react';
function AdjustWallet() {
const [open, setOpen] = useState(false);
const [last, setLast] = useState<WalletAdjustment | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Adjust wallet</Button>
<small>{last ? `Saved ${last.amount}: ${last.reason}` : 'Nothing saved yet'}</small>
<AdjustWalletDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" available="43390.00" money={{ decimals: 'auto' }} onSave={(a) => { setLast(a); setOpen(false); }} />
</div>
);
}TRNDR fee
0 to BRAND_FEE_MAX (50) % with up to two decimals, checked by parseBrandFee ("7.5" gives "7.50", "50.01" gives null). "Use default (5%)" shows while the brand has its own fee, and saving an empty field uses the default too; without onUseDefault an empty field is an error. A failed save shows error; busy locks the buttons.
Code
import { BrandFeeDialog, Button } from '@ergasti/bricks';
import { useState } from 'react';
function Fee() {
const [open, setOpen] = useState(false);
const [fee, setFee] = useState<string | null>('7.5');
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Change fee</Button>
<small>Fee: {fee === null ? '5% (default)' : `${fee}%`}</small>
<BrandFeeDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" value={fee} defaultFee="5" onSave={(v) => { setFee(v); setOpen(false); }} onUseDefault={() => { setFee(null); setOpen(false); }} />
</div>
);
}Arabic
Code
import { AdjustWalletDialog, Button } from '@ergasti/bricks';
import { useState } from 'react';
function Arabic() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>عدّل المحفظة</Button>
<AdjustWalletDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" available="43390.00" onSave={() => setOpen(false)} language="ar" />
</>
);
}payoutColumns
function
The payoutColumns DataTable column preset. money: how its money cells are shown (slot presets.figures, over the provider).
function payoutColumns(language: Lang, on: { onReceipt: (row: PayoutRow) => void; }, copy?: Partial<PrColumnsCopy> | undefined, money?: MoneyDisplay | undefined): DataColumn<PayoutRow>[]Prop
Type
Source: src/pr/presets.tsx (line 154)
Join requests table
The column preset gives the creator, followers, brand, source, waiting time and the approve and reject buttons, in the page's language; you give the handlers and the rows. The preset's sort keys are named after the row fields.
Code
import { useState } from 'react';
import { DataTable, joinRequestColumns } from '@ergasti/bricks';
import { joinRequests } from './pr';
function JoinRequests() {
const [selected, setSelected] = useState<ReadonlySet<string | number>>(new Set([1, 2]));
return (
<DataTable
label="Join requests" rows={joinRequests} rowKey={(r) => r.id}
columns={joinRequestColumns('en', { onApprove: () => {}, onReject: () => {}, onOpen: () => {} })}
selection={{ selected, onChange: setSelected, rowLabel: (r) => r.creator.name }}
sort={{ key: 'waiting', dir: 'desc' }} onSort={() => {}}
/>
);
}The other presets
Brands, payouts (with a receipt button), wallet top-ups (with a confirm button), announcements and the audit log: each is xColumns(language, handlers) returning DataColumn<Row>[] for DataTable.
Code
import { DataTable, auditColumns, brandColumns, messageColumns, payoutColumns, topUpColumns } from '@ergasti/bricks';
import { auditEntries, brandRows, messages, payouts, topUps } from './pr';
function MorePresets() {
return (
<div style={{ display: 'grid', gap: 24 }}>
<DataTable label="Brands" rows={brandRows} rowKey={(r) => r.id} columns={brandColumns('en')} onRowClick={() => {}} />
<DataTable label="Payouts" rows={payouts} rowKey={(r) => r.id} columns={payoutColumns('en', { onReceipt: () => {} })} />
<DataTable label="Top-ups" rows={topUps} rowKey={(r) => r.id} columns={topUpColumns('en', { onConfirm: () => {} })} />
<DataTable label="Messages" rows={messages} rowKey={(r) => r.id} columns={messageColumns('en')} onRowClick={() => {}} />
<DataTable label="Audit log" rows={auditEntries} rowKey={(r) => r.id} columns={auditColumns('en')} />
</div>
);
}PR_PORTAL_NAV
constant
The PR portal v3 navigation, as PrPortalFrame draws it by default: Home, Approvals, Brands; "Campaigns" with Affiliate programs, Gift stock and Gift analytics indented under it; Creators, Tiers, Messages, Activity log; and "Next sprint" with Payouts and Settings shown disabled with a LATER badge. Labels in both languages; no counts. Copy it and add count to items ({ ...item, count: 9 }) or change it to build your own.
const PR_PORTAL_NAV: readonly NavGroup[]Source: src/pr/portal/PrPortalFrame.tsx (line 90)
The PR portal frame
One component for the whole PR portal v3 frame: the dark sidebar with the v3 nav, the Open decisions card, the signed-in person with sign-out, and the header with the screen's own tools, search, the bell and the raspberry "+ New". The card's "Show decision tags" switch drives a DecisionTagsProvider around the page, so the tag after "Shipments from brands" comes and goes. Pick another item in the sidebar to move.
Code
import { useState } from 'react';
import { Button, Card, DecisionTag, Icon, PR_PORTAL_NAV, PrPortalFrame, type NavItem, type NotificationItem } from '@ergasti/bricks';
const OPEN = [
{ id: 'C3', question: 'Can a brand opt out of a TRNDR-wide challenge?' },
{ id: 'R10', question: 'What a tier gives creators' },
{ id: 'GS1', question: 'Damaged or extra units: brand collects within 14 days?' },
];
const NOTIFS: NotificationItem[] = [
{ id: 1, text: <><b>Sara Ali</b> has waited 8 days to join Glow Lab.</>, when: '1 hour ago', icon: 'approvals', tone: 'rasp', unread: true },
{ id: 2, text: <><b>Kemet Home</b> wallet is below zero (day 4 of 7).</>, when: 'Today', icon: 'wallet', tone: 'butter', unread: true },
{ id: 3, text: <><b>4 new creators</b> are waiting for approval.</>, when: 'Yesterday', icon: 'user', tone: 'sky', unread: false },
];
const COUNTS: Record<string, number> = { approvals: 9, programs: 3, gifts: 3 };
const nav = PR_PORTAL_NAV.map((group) => ({ ...group, items: group.items.map((item) => (COUNTS[item.id] ? { ...item, count: COUNTS[item.id] } : item)) }));
function Frame() {
const [active, setActive] = useState('gifts');
const [items, setItems] = useState(NOTIFS);
return (
<PrPortalFrame
nav={nav} activeId={active} onNavigate={(item: NavItem) => setActive(item.id)}
decisions={OPEN} user={{ name: 'Mona Adel', seed: 1 }} onSignOut={() => {}}
title="Gift stock" subtitle="Brands send gifts to the warehouse and tell us what they sent. Nothing counts as gift stock until you confirm what arrived."
tools={<Button><Icon name="plus" />Record gifts for a brand</Button>}
search={{ fetcher: async () => [], onSelect: () => {} }}
notifications={{ items, onOpenItem: (id) => setItems((all) => all.map((n) => (n.id === id ? { ...n, unread: false } : n))), onMarkAllRead: () => setItems((all) => all.map((n) => ({ ...n, unread: false }))), onSeeAll: () => setActive('activity') }}
newMenu={[{ id: 'gift', label: 'Record gifts', sub: 'Boxes a brand sent without a claim', icon: 'gift' }]}
>
<Card title={<>Shipments from brands<DecisionTag id="GS1" question="Damaged or extra units: brand collects within 14 days?" /></>}>The screen goes here.</Card>
</PrPortalFrame>
);
}A brand page
titleLead puts the brand's big square before its name in the h1, breadcrumbs the crumb above it, and tools the page's own "View as brand" before the search. On brand pages the "+ New" menu offers both a challenge and gifts.
Code
import { BrandAvatar, Button, Card, Icon, PR_PORTAL_NAV, PrPortalFrame } from '@ergasti/bricks';
const OPEN = [
{ id: 'C3', question: 'Can a brand opt out of a TRNDR-wide challenge?' },
{ id: 'R10', question: 'What a tier gives creators' },
{ id: 'GS1', question: 'Damaged or extra units: brand collects within 14 days?' },
];
const COUNTS: Record<string, number> = { approvals: 9, programs: 3, gifts: 3 };
const nav = PR_PORTAL_NAV.map((group) => ({ ...group, items: group.items.map((item) => (COUNTS[item.id] ? { ...item, count: COUNTS[item.id] } : item)) }));
function BrandPage() {
return (
<PrPortalFrame
nav={nav} activeId="brands" decisions={OPEN} user={{ name: 'Mona Adel', seed: 1 }} onSignOut={() => {}}
title="Glow Lab" titleLead={<BrandAvatar name="Glow Lab" color="#C7325C" size="lg" />} breadcrumbs={<><a href="#brands">Brands</a> / Glow Lab</>}
tools={<Button><Icon name="eye" />View as brand</Button>}
search={{ fetcher: async () => [], onSelect: () => {} }}
newMenu={[{ id: 'ch', label: 'Challenge', sub: 'For one brand or all brands', icon: 'star' }, { id: 'gift', label: 'Record gifts', icon: 'gift' }]}
>
<Card title="Affiliate program">10% of sale</Card>
</PrPortalFrame>
);
}On a phone
Under 860px the sidebar becomes a tab bar and a "More" sheet; the sheet holds the whole nav, then the Open decisions card with its switch, then the person's row with sign-out. Open "More" to see them.
Code
import { useState } from 'react';
import { Card, PR_PORTAL_NAV, PrPortalFrame, Segmented } from '@ergasti/bricks';
const OPEN = [
{ id: 'C3', question: 'Can a brand opt out of a TRNDR-wide challenge?' },
{ id: 'R10', question: 'What a tier gives creators' },
{ id: 'GS1', question: 'Damaged or extra units: brand collects within 14 days?' },
];
const COUNTS: Record<string, number> = { approvals: 9, programs: 3, gifts: 3 };
const nav = PR_PORTAL_NAV.map((group) => ({ ...group, items: group.items.map((item) => (COUNTS[item.id] ? { ...item, count: COUNTS[item.id] } : item)) }));
function Phone() {
const [scope, setScope] = useState<'my' | 'all'>('my');
return (
<div style={{ maxWidth: 390 }}>
<PrPortalFrame
tier="mobile" nav={nav} activeId="home" decisions={OPEN} user={{ name: 'منى عادل', seed: 1 }} onSignOut={() => {}}
title="صباح الخير يا منى" subtitle="13 حاجة مستنياك. الأهم الأول."
tools={<Segmented label="البراندات اللي ظاهرة" size="sm" value={scope} onChange={setScope} options={[['my', 'براندات بتاعتي'], ['all', 'كل البراندات']]} />}
search={{ fetcher: async () => [], onSelect: () => {} }}
>
<Card title="محتاجك">…</Card>
</PrPortalFrame>
</div>
);
}prCreatorColumns
function
deprecated
Deprecated
Since 0.7.0. Use creatorColumns(language, money, { onOpen, reapply: true, nullableSales: true }) with
PrCreatorRow rows: the same columns, the reapply tooltip and the nullable sales as opt-ins. Keeps working until 1.0.
The PR Creators table as a DataTable column preset (the PR v3 mock's creators table): creator (photo, name, handle or "Customer", since when), status, tier, score, followers, their brands' squares, orders and all-time sales. Named prCreatorColumns beside the brand console's creator lists. on.onOpen makes the name a button (the row also opens with DataTable onRowClick). money: how sales are shown, over the provider's money and moneyFor['prCreatorColumns.sales'] (the slot's default: cents only when non-zero).
function prCreatorColumns(language: Lang, on?: { onOpen?: (row: PrCreatorListRow) => void; }, copy?: Partial<{ readonly creator: string; readonly status: string; readonly tier: string; readonly score: string; readonly followers: string; readonly brands: string; readonly orders: string; readonly sales: string; readonly since: (when: string) => string; readonly customer: string; readonly reapply: (when: string) => string; readonly none: string; }> | undefined, money?: MoneyDisplay | undefined): DataColumn<PrCreatorListRow>[]Prop
Type
Source: src/pr/creatorColumns.tsx (line 67)
Creators table
The PR Creators list: photo with name and handle (or "Customer") and since when, status, tier, TRNDR score, followers by platform, their brands' squares, orders and all-time sales. Anything missing reads "—" (and "None" to a screen reader); a rejected creator's pill says when they can apply again. Deprecated since 0.7.0: use creatorColumns with its reapply and nullableSales options, which draws the same table.
Code
import { DataTable, prCreatorColumns, type PrCreatorListRow } from '@ergasti/bricks';
const B = { glow: { id: 'glow', name: 'Glow Lab', color: '#C7325C' }, nile: { id: 'nile', name: 'Nile Threads', color: '#2C45A6' }, mira: { id: 'mira', name: 'Mira Beauty', color: '#5B3BB0' }, kemet: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' } };
const CREATORS: PrCreatorListRow[] = [
{ id: 1, creator: { name: 'Nour Hassan', seed: 1 }, joined: 'Jun 2026', status: 'creator_active', tier: 'elite', score: 91, followers: { instagram: 120000, tiktok: 340000 }, brands: [B.glow, B.mira, B.kemet, B.nile], orders: 702, sales: '212000.00' },
{ id: 2, creator: { name: 'Sara Ali', seed: 2, handle: '@sara.ali' }, joined: 'Aug 2026', status: 'creator_active', tier: 'established', score: 62, followers: { instagram: 24000, tiktok: 61000 }, brands: [B.nile], orders: 208, sales: '64300.00' },
{ id: 3, creator: { name: 'Omar Khaled', seed: 3 }, customer: true, joined: 'Nov 2026', status: 'pending', tier: null, score: null, followers: { tiktok: 33000 }, brands: [], orders: 0, sales: '0.00' },
{ id: 4, creator: { name: 'Rana Fathy', seed: 4 }, joined: 'Oct 2026', status: 'rejected', reapply: '1 Dec', brands: [], orders: 0, sales: null },
];
function Creators() {
return <DataTable label="Creators" rows={CREATORS} rowKey={(r) => r.id} columns={prCreatorColumns('en', { onOpen: () => {} })} onRowClick={() => {}} sort={{ key: 'sales', dir: 'desc' }} onSort={() => {}} />;
}Empty and loading
Filters that match nobody show the table's empty state with Clear filters; loading draws skeleton rows.
Code
import { DataTable, prCreatorColumns, type PrCreatorListRow } from '@ergasti/bricks';
function EmptyAndLoading() {
return (
<div style={{ display: 'grid', gap: 16 }}>
<DataTable label="Creators" rows={[]} rowKey={(r: PrCreatorListRow) => r.id} columns={prCreatorColumns('en')} onClearFilters={() => {}} />
<DataTable label="Creators" rows={[]} rowKey={(r: PrCreatorListRow) => r.id} columns={prCreatorColumns('en')} loading loadingRows={3} />
</div>
);
}In Arabic
Headers, statuses, tiers and money read in Arabic; names and handles keep their own direction.
Code
import { DataTable, prCreatorColumns, type PrCreatorListRow } from '@ergasti/bricks';
const B = { glow: { id: 'glow', name: 'Glow Lab', color: '#C7325C' }, nile: { id: 'nile', name: 'Nile Threads', color: '#2C45A6' }, mira: { id: 'mira', name: 'Mira Beauty', color: '#5B3BB0' }, kemet: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' } };
const CREATORS: PrCreatorListRow[] = [
{ id: 1, creator: { name: 'Nour Hassan', seed: 1 }, joined: 'Jun 2026', status: 'creator_active', tier: 'elite', score: 91, followers: { instagram: 120000, tiktok: 340000 }, brands: [B.glow, B.mira, B.kemet, B.nile], orders: 702, sales: '212000.00' },
{ id: 2, creator: { name: 'Sara Ali', seed: 2, handle: '@sara.ali' }, joined: 'Aug 2026', status: 'creator_active', tier: 'established', score: 62, followers: { instagram: 24000, tiktok: 61000 }, brands: [B.nile], orders: 208, sales: '64300.00' },
{ id: 3, creator: { name: 'Omar Khaled', seed: 3 }, customer: true, joined: 'Nov 2026', status: 'pending', tier: null, score: null, followers: { tiktok: 33000 }, brands: [], orders: 0, sales: '0.00' },
{ id: 4, creator: { name: 'Rana Fathy', seed: 4 }, joined: 'Oct 2026', status: 'rejected', reapply: '1 Dec', brands: [], orders: 0, sales: null },
];
function Arabic() {
return (
<div dir="rtl">
<DataTable label="صنّاع المحتوى" rows={CREATORS} rowKey={(r) => r.id} columns={prCreatorColumns('ar')} language="ar" />
</div>
);
}Money display
All-time sales use the prCreatorColumns.sales money slot: cents only when not zero by default ("EGP 212,000"). Here the app sets BricksProvider moneyFor to the compact form ("EGP 212.0K"); the preset's last argument (money) would win over it.
Code
import { BricksProvider, DataTable, prCreatorColumns, type PrCreatorListRow } from '@ergasti/bricks';
const B = { glow: { id: 'glow', name: 'Glow Lab', color: '#C7325C' }, nile: { id: 'nile', name: 'Nile Threads', color: '#2C45A6' }, mira: { id: 'mira', name: 'Mira Beauty', color: '#5B3BB0' }, kemet: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' } };
const CREATORS: PrCreatorListRow[] = [
{ id: 1, creator: { name: 'Nour Hassan', seed: 1 }, joined: 'Jun 2026', status: 'creator_active', tier: 'elite', score: 91, followers: { instagram: 120000, tiktok: 340000 }, brands: [B.glow, B.mira, B.kemet, B.nile], orders: 702, sales: '212000.00' },
{ id: 2, creator: { name: 'Sara Ali', seed: 2, handle: '@sara.ali' }, joined: 'Aug 2026', status: 'creator_active', tier: 'established', score: 62, followers: { instagram: 24000, tiktok: 61000 }, brands: [B.nile], orders: 208, sales: '64300.00' },
{ id: 3, creator: { name: 'Omar Khaled', seed: 3 }, customer: true, joined: 'Nov 2026', status: 'pending', tier: null, score: null, followers: { tiktok: 33000 }, brands: [], orders: 0, sales: '0.00' },
{ id: 4, creator: { name: 'Rana Fathy', seed: 4 }, joined: 'Oct 2026', status: 'rejected', reapply: '1 Dec', brands: [], orders: 0, sales: null },
];
function MoneyDisplay() {
return (
<BricksProvider moneyFor={{ 'prCreatorColumns.sales': { compact: true } }}>
<DataTable label="Creators" rows={CREATORS.slice(0, 2)} rowKey={(r) => r.id} columns={prCreatorColumns('en')} />
</BricksProvider>
);
}senderModes
function
The modes each sender may use (the mock's cmTo): TRNDR reaches anyone; a brand only its own creators.
function senderModes(sender: string | number | null, offered: readonly ("group" | "all" | "brand" | "tier" | "picked")[]): ("group" | "all" | "brand" | "tier" | "picked")[]Prop
Type
Source: src/pr/AnnouncementComposer.tsx (line 43)
smsCount
function
How an SMS body splits: GSM-7 fits 160 characters in one message and 153 per part when it splits; any other character (Arabic, emoji) switches the whole message to UCS-2: 70, then 67 per part.
function smsCount(text: string): SmsCountProp
Type
Source: src/pr/sms.ts (line 17)
Subject and body
A subject (not for SMS) and a body with character counters; for SMS the counter reports segments and the encoding (smsCount). Errors are yours to pass.
Code
import { useState } from 'react';
import { MessageFields, smsCount } from '@ergasti/bricks';
function Fields() {
const [subject, setSubject] = useState('Winter top 10');
const [body, setBody] = useState('Two weeks left. Share your Glow Lab coupon in stories this weekend.');
return (
<div style={{ display: 'grid', gap: 16, maxWidth: 560 }}>
<MessageFields channel="sms" subject={subject} body={body} onSubject={setSubject} onBody={setBody} bodyMax={480} />
<small>smsCount: {JSON.stringify(smsCount(body))}</small>
</div>
);
}Preview
What the creator sees on each channel, with the sender's name.
Code
import { MessagePreview } from '@ergasti/bricks';
import { brands } from './pr';
function Preview() {
return (
<div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 1fr))' }}>
<MessagePreview channel="app" sender={brands.glow} subject="Winter top 10" body="Two weeks left. Share your coupon in stories." />
<MessagePreview channel="sms" sender={null} subject="" body="TRNDR: two weeks left in Winter top 10." />
</div>
);
}Errors and a shorter subject
errors marks the subject and the body with your messages; subjectMax sets the subject's counter (default 80).
Code
import { useState } from 'react';
import { MessageFields } from '@ergasti/bricks';
function Invalid() {
const [subject, setSubject] = useState('');
const [body, setBody] = useState('Hi');
return (
<div style={{ maxWidth: 560 }}>
<MessageFields
channel="app" subject={subject} body={body} onSubject={setSubject} onBody={setBody} subjectMax={40}
errors={{ subject: subject ? undefined : 'Add a subject.', body: body.length < 10 ? 'Write at least 10 characters.' : undefined }}
/>
</div>
);
}tierName
function
A tier's name from the provider's tiers (the TRNDR preset's TRNDR_TIERS with no provider); else the key.
function tierName(tiers: Readonly<Record<string, TierDef>>, tier: string, language: Lang): stringProp
Type
Source: src/pr/types.ts (line 9)
toPrChallengeCard
function
The card's props from a table row: the same object without its id (<PrChallengeCard {...toPrChallengeCard(row)} />).
function toPrChallengeCard(options: PrChallengeRow): PrChallengeDataoptions: PrChallengeRow (required)
Prop
Type
Source: src/pr/challenges/PrChallengeCard.tsx (line 94)
Challenges table
The Challenges tab's Table view: the challenge with its type and audience, the brand over its dates, the goal and reward chips ("No gifts left" when a gift reward has no stock), the days left (raspberry at 3 or fewer; the status pill when not live), how many joined and the budget held.
Code
import { DataTable, challengeTableColumns, type PrChallengeRow } from '@ergasti/bricks';
import { brands } from './pr';
const rows: PrChallengeRow[] = [
{ id: 'winter', name: 'Winter top 10', type: 'leader', audience: 'public', brand: brands.glow, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: 'Top 10 by delivered sales', reward: 'EGP 1,000 each', joined: 64, held: '10000.00' },
{ id: 'sell20', name: 'Sell 20 in November', type: 'target', audience: 'brand', brand: brands.mira, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: '20 delivered orders', reward: 'Serum gift set', rewardKind: 'gift', noGiftsLeft: true, hit: 9, joined: 23, held: '7800.00' },
{ id: 'sprint', name: 'Weekend sprint', type: 'target', audience: 'brand', brand: brands.kemet, status: 'live', dates: '14–16 Nov', daysLeft: 1, timeProgress: 70, goal: 'EGP 5,000 delivered sales', reward: 'EGP 300 each', hit: 7, joined: 18, held: '6000.00' },
{ id: 'spring', name: 'Spring boost', type: 'boost', audience: 'public', brand: brands.nile, status: 'upcoming', dates: '1–14 Dec', goal: '×2 commission', reward: 'Up to EGP 5,000', joined: 0, held: '5000.00' },
];
function Table() {
return <DataTable label="Challenges" columns={challengeTableColumns('en', { onOpen: () => {} }, { decimals: 'auto' })} rows={rows} rowKey={(r) => r.id} onRowClick={() => {}} sort={{ key: 'held', dir: 'desc' }} onSort={() => {}} />;
}Cards or Table, one mapper
PrChallengeRow is PrChallengeCard's data plus an id, so the API's challenges are mapped once and feed both views; toPrChallengeCard(row) hands a row to the card.
Code
import { useState } from 'react';
import { DataTable, PrChallengeCard, Segmented, challengeTableColumns, toPrChallengeCard, type PrChallengeRow } from '@ergasti/bricks';
import { brands } from './pr';
const rows: PrChallengeRow[] = [
{ id: 'winter', name: 'Winter top 10', type: 'leader', audience: 'public', brand: brands.glow, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: 'Top 10 by delivered sales', reward: 'EGP 1,000 each', joined: 64, held: '10000.00' },
{ id: 'sell20', name: 'Sell 20 in November', type: 'target', audience: 'brand', brand: brands.mira, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: '20 delivered orders', reward: 'Serum gift set', rewardKind: 'gift', noGiftsLeft: true, hit: 9, joined: 23, held: '7800.00' },
{ id: 'sprint', name: 'Weekend sprint', type: 'target', audience: 'brand', brand: brands.kemet, status: 'live', dates: '14–16 Nov', daysLeft: 1, timeProgress: 70, goal: 'EGP 5,000 delivered sales', reward: 'EGP 300 each', hit: 7, joined: 18, held: '6000.00' },
{ id: 'spring', name: 'Spring boost', type: 'boost', audience: 'public', brand: brands.nile, status: 'upcoming', dates: '1–14 Dec', goal: '×2 commission', reward: 'Up to EGP 5,000', joined: 0, held: '5000.00' },
];
function CardsOrTable() {
const [view, setView] = useState<'cards' | 'table'>('table');
return (
<div style={{ display: 'grid', gap: 16 }}>
<Segmented size="sm" label="View" value={view} onChange={setView} options={[['cards', 'Cards'], ['table', 'Table']]} />
{view === 'table'
? <DataTable label="Challenges" columns={challengeTableColumns('en', {}, { decimals: 'auto' })} rows={rows} rowKey={(r) => r.id} onRowClick={() => {}} />
: <div className="kit-prc-grid">{rows.map((r) => <PrChallengeCard key={r.id} {...toPrChallengeCard(r)} onOpen={() => {}} money={{ decimals: 'auto' }} />)}</div>}
</div>
);
}In Arabic
Headers, type and audience and "يوم" read in Arabic; names stay in their own script.
Code
import { DataTable, challengeTableColumns, type PrChallengeRow } from '@ergasti/bricks';
import { brands } from './pr';
const rows: PrChallengeRow[] = [
{ id: 'winter', name: 'Winter top 10', type: 'leader', audience: 'public', brand: brands.glow, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: 'Top 10 by delivered sales', reward: 'EGP 1,000 each', joined: 64, held: '10000.00' },
{ id: 'sell20', name: 'Sell 20 in November', type: 'target', audience: 'brand', brand: brands.mira, status: 'live', dates: '1–30 Nov', daysLeft: 15, timeProgress: 50, goal: '20 delivered orders', reward: 'Serum gift set', rewardKind: 'gift', noGiftsLeft: true, hit: 9, joined: 23, held: '7800.00' },
{ id: 'sprint', name: 'Weekend sprint', type: 'target', audience: 'brand', brand: brands.kemet, status: 'live', dates: '14–16 Nov', daysLeft: 1, timeProgress: 70, goal: 'EGP 5,000 delivered sales', reward: 'EGP 300 each', hit: 7, joined: 18, held: '6000.00' },
{ id: 'spring', name: 'Spring boost', type: 'boost', audience: 'public', brand: brands.nile, status: 'upcoming', dates: '1–14 Dec', goal: '×2 commission', reward: 'Up to EGP 5,000', joined: 0, held: '5000.00' },
];
function Arabic() {
return <DataTable label="التحديات" language="ar" columns={challengeTableColumns('ar', {}, { decimals: 'auto' })} rows={rows} rowKey={(r) => r.id} onRowClick={() => {}} />;
}topUpColumns
function
The topUpColumns DataTable column preset. money: how its money cells are shown (slot presets.figures, over the provider).
function topUpColumns(language: Lang, on: { onConfirm?: (row: TopUpRow) => void; }, copy?: Partial<PrColumnsCopy> | undefined, money?: MoneyDisplay | undefined): DataColumn<TopUpRow>[]Prop
Type
Source: src/pr/presets.tsx (line 183)
Join requests table
The column preset gives the creator, followers, brand, source, waiting time and the approve and reject buttons, in the page's language; you give the handlers and the rows. The preset's sort keys are named after the row fields.
Code
import { useState } from 'react';
import { DataTable, joinRequestColumns } from '@ergasti/bricks';
import { joinRequests } from './pr';
function JoinRequests() {
const [selected, setSelected] = useState<ReadonlySet<string | number>>(new Set([1, 2]));
return (
<DataTable
label="Join requests" rows={joinRequests} rowKey={(r) => r.id}
columns={joinRequestColumns('en', { onApprove: () => {}, onReject: () => {}, onOpen: () => {} })}
selection={{ selected, onChange: setSelected, rowLabel: (r) => r.creator.name }}
sort={{ key: 'waiting', dir: 'desc' }} onSort={() => {}}
/>
);
}The other presets
Brands, payouts (with a receipt button), wallet top-ups (with a confirm button), announcements and the audit log: each is xColumns(language, handlers) returning DataColumn<Row>[] for DataTable.
Code
import { DataTable, auditColumns, brandColumns, messageColumns, payoutColumns, topUpColumns } from '@ergasti/bricks';
import { auditEntries, brandRows, messages, payouts, topUps } from './pr';
function MorePresets() {
return (
<div style={{ display: 'grid', gap: 24 }}>
<DataTable label="Brands" rows={brandRows} rowKey={(r) => r.id} columns={brandColumns('en')} onRowClick={() => {}} />
<DataTable label="Payouts" rows={payouts} rowKey={(r) => r.id} columns={payoutColumns('en', { onReceipt: () => {} })} />
<DataTable label="Top-ups" rows={topUps} rowKey={(r) => r.id} columns={topUpColumns('en', { onConfirm: () => {} })} />
<DataTable label="Messages" rows={messages} rowKey={(r) => r.id} columns={messageColumns('en')} onRowClick={() => {}} />
<DataTable label="Audit log" rows={auditEntries} rowKey={(r) => r.id} columns={auditColumns('en')} />
</div>
);
}TRNDR_SCORE_PARTS
constant
The TRNDR score's parts and the points each can give (Creator Pulse v2: the backend's PulseScoreV2, config affiliate.pulse.v2): nine parts, 100 points. Names and "what it measures" are in the components' copy, by key.
const TRNDR_SCORE_PARTS: readonly [{ readonly key: "followers"; readonly max: 20; }, { readonly key: "engagement"; readonly max: 25; }, { readonly key: "approved_tasks"; readonly max: 10; }, { readonly key: "packages_done"; readonly max: 10; }, { readonly key: "verified_accounts"; readonly max: 5; }, { readonly key: "posting"; readonly max: 5; }, { readonly key: "growth"; readonly max: 5; }, { readonly key: "on_time"; readonly max: 10; }, { readonly key: "quality"; readonly max: 10; }]Source: src/pr/creators/Score.tsx (line 12)
usagePercent
function
How much of a total is used, 0–100, rounded down so 100 only means all used (0 for an empty total).
function usagePercent(used: number, total: number): numberProp
Type
Source: src/pr/ganalytics/UsageBar.tsx (line 21)
waitingReminder
function
The reminder rule (R6): a reminder after 2 days, a second after a week; a week or more is overdue (red).
function waitingReminder(waited: number): "none" | "first" | "second"Prop
Type
Source: src/pr/Approvals.tsx (line 31)
warehouseMapsUrl
function
A Google Maps search for an address (the mock's link).
function warehouseMapsUrl(address: string): stringProp
Type
Source: src/pr/gifts/Warehouse.tsx (line 45)
Record gifts a brand sent without a claim: the warehouse banner, the brand's products with units, boxes and where they are now
Code
import { useState } from 'react';
import { Button, RecordGiftsDialog, type WarehouseDetails } from '@ergasti/bricks';
const WH: WarehouseDetails = { address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza (sample)', hours: 'Sun–Thu · 10:00–17:00', phone: '+20 100 000 0000' };
const brands = [
{ id: 'glow', name: 'Glow Lab', products: ['Red lipstick', 'Eyeshadow palette', 'Lash mascara'].map((name, i) => ({ id: `g${i}`, name, sku: `GL-${101 + i}` })) },
{ id: 'nile', name: 'Nile Threads', products: ['Linen shirt', 'Cotton tote'].map((name, i) => ({ id: `n${i}`, name, sku: `NI-${101 + i}` })) },
];
function RecordGifts() {
const [open, setOpen] = useState(false);
const [last, setLast] = useState('');
return (
<>
<Button onClick={() => setOpen(true)}>Record gifts for a brand</Button> <small>{last}</small>
<RecordGiftsDialog open={open} onClose={() => setOpen(false)} brands={brands} warehouse={WH}
onSave={(g) => { setLast(`${g.lines.reduce((a, l) => a + l.units, 0)} units, ${g.boxes} boxes, ${g.state}`); setOpen(false); }} />
</>
);
}Where brands send gifts: the "Send to:" banner (with a Maps link) and the card PR edits it in
Code
import { useState } from 'react';
import { WarehouseDetailsCard, WarehouseNote, type WarehouseDetails } from '@ergasti/bricks';
const WH: WarehouseDetails = { address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza (sample)', hours: 'Sun–Thu · 10:00–17:00', phone: '+20 100 000 0000' };
function Warehouse() {
const [wh, setWh] = useState(WH);
return (
<div style={{ display: 'grid', gap: 16 }}>
<WarehouseNote warehouse={wh} />
<WarehouseDetailsCard value={wh} onSave={setWh} />
</div>
);
}Saving
Pass busy while your request runs: Save is disabled. defaultBrandId opens the dialog on one brand (from that brand's page).
Code
import { RecordGiftsDialog, type WarehouseDetails } from '@ergasti/bricks';
const WH: WarehouseDetails = { address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza (sample)', hours: 'Sun–Thu · 10:00–17:00', phone: '+20 100 000 0000' };
const brands = [
{ id: 'glow', name: 'Glow Lab', products: ['Red lipstick', 'Eyeshadow palette', 'Lash mascara'].map((name, i) => ({ id: `g${i}`, name, sku: `GL-${101 + i}` })) },
{ id: 'nile', name: 'Nile Threads', products: ['Linen shirt', 'Cotton tote'].map((name, i) => ({ id: `n${i}`, name, sku: `NI-${101 + i}` })) },
];
function Busy() {
return <RecordGiftsDialog open onClose={() => {}} onSave={() => {}} busy defaultBrandId="nile" brands={brands} warehouse={WH} />;
}Server error
When saving fails, pass its message as error: it is announced in the footer and what the user filled in stays.
Code
import { RecordGiftsDialog, type WarehouseDetails } from '@ergasti/bricks';
const WH: WarehouseDetails = { address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza (sample)', hours: 'Sun–Thu · 10:00–17:00', phone: '+20 100 000 0000' };
const brands = [
{ id: 'glow', name: 'Glow Lab', products: ['Red lipstick', 'Eyeshadow palette', 'Lash mascara'].map((name, i) => ({ id: `g${i}`, name, sku: `GL-${101 + i}` })) },
{ id: 'nile', name: 'Nile Threads', products: ['Linen shirt', 'Cotton tote'].map((name, i) => ({ id: `n${i}`, name, sku: `NI-${101 + i}` })) },
];
function ServerError() {
return <RecordGiftsDialog open onClose={() => {}} onSave={() => {}} error="We could not save these gifts. Try again." brands={brands} warehouse={WH} />;
}Another cap
maxUnits (default 999, the mock's rule) is the most units one product may hold; set it, and the error names the range ("Enter 1 to 5,000 units for each ticked product"). Tick a product, type 6000 and Save to see it.
Code
import { RecordGiftsDialog } from '@ergasti/bricks';
const brands = [
{ id: 'glow', name: 'Glow Lab', products: ['Red lipstick', 'Eyeshadow palette', 'Lash mascara'].map((name, i) => ({ id: `g${i}`, name, sku: `GL-${101 + i}` })) },
{ id: 'nile', name: 'Nile Threads', products: ['Linen shirt', 'Cotton tote'].map((name, i) => ({ id: `n${i}`, name, sku: `NI-${101 + i}` })) },
];
function MaxUnits() {
return <RecordGiftsDialog open onClose={() => {}} onSave={() => {}} maxUnits={5000} brands={brands} />;
}