CustomerAffiliatesCard
A brand's customer affiliates (the v3 mock's custCard, saveCRate, rotateCL): the customer rate with its rule (above 0, below the creator rate; checked on save and said under the field), "Also move the N customers who already joined", Save customer rate; then the facts (who can join, customers, their sales, seats, tier/score/gifts/challenges) and the customer link with Copy, Make a new link (asks first) and Turn link off / on. The pill says Link on, Link off or Off for all brands. Copying says so in a live region.
import { CustomerAffiliatesCard } from '@ergasti/bricks';Examples
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>;
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prCustomerCard, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
title | Customer affiliates | أفلييت العملاء |
rateLabel | Customer rate ({unit}) | عمولة العملاء ({unit}) |
unitPercent | % | % |
unitItem | {currency} per item | {currency} على القطعة |
hint | [object Object] | [object Object] |
errInvalid | Enter a rate above 0. | اكتب عمولة أكبر من صفر. |
errNotBelow | [object Object] | [object Object] |
moveAll | Also move the {n} customers who already joined to this rate | انقل كمان الـ {n} عميل اللي اشتركوا قبل كده للعمولة دي |
save | Save customer rate | احفظ عمولة العملاء |
whoCanJoin | Who can join | مين يقدر يشترك |
whoValue | Only people with a delivered order at {brand} | بس اللي عندهم طلب اتسلّم من {brand} |
customers | Customers | العملاء |
sales | Their sales | مبيعاتهم |
seats | Seats used | الأماكن المستخدمة |
extras | Tier, score, gifts, challenges | المستوى والسكور والهدايا والتحديات |
none | None | ولا حاجة |
link | Customer link | لينك العملاء |
copy | Copy | انسخ |
copyName | Copy the customer link | انسخ لينك العملاء |
copied | Customer link copied | اتنسخ لينك العملاء |
copyFailed | Couldn’t copy. Select the link and copy it. | معرفناش ننسخ. علّم على اللينك وانسخه. |
newLink | Make a new link | اعمل لينك جديد |
linkOff | Turn link off | اقفل اللينك |
linkOn | Turn link on | شغّل اللينك |
note | {brand} can copy and share the link. Only PR changes or stops it. | {brand} يقدر ينسخ اللينك وينشره. الـ PR بس اللي يغيّره أو يوقفه. |
newTitle | Make a new customer link? | تعمل لينك عملاء جديد؟ |
newBody | The old link stops working straight away. {brand} sees the new one in its portal. Customers who already joined are not affected. | اللينك القديم بيقف على طول. {brand} هيشوف الجديد في البوابة بتاعته. العملاء اللي اشتركوا قبل كده مش هيتأثروا. |
cancel | Cancel | إلغاء |
Design guidance
How the BRICKS design system uses CustomerAffiliatesCard. Written in docs/content/components/CustomerAffiliatesCard.md; the props above are read from the code, which wins where the two disagree.
One brand's customer affiliates: the customer rate with its rule, "move existing customers", the facts, and the customer link with Copy, Make a new link and Turn link off; use it on the PR campaign page.
CustomerAffiliatesCard is the v3 mock's custCard, saveCRate and rotateCL. The customer rate is in the brand's commission unit and must be above 0 and below the creator rate; the rule (customerRateIssue) is checked exactly in hundredths when PR saves and explained under the field. The right half lists who can join, how many customers and their sales, and that customers take no seats, tier, score, gifts or challenges. The link can be copied (announced politely), renewed after a confirmation (the old one stops) or turned off.
Anatomy
- Card head: "Customer affiliates" and a pill: Link on (green), Link off (grey) or Off for all brands (grey, when the platform switch is off).
- Rate column:
FormField"Customer rate (%)" or "Customer rate (EGP per item)" (text input, decimal,dir="ltr"), hint "Must be above 0 and below the creator rate (10% of sale). Glow Lab only sees it."; checkbox "Also move the 38 customers who already joined to this rate"; ink "Save customer rate"; error alert. - Facts column: a key-value list: Who can join (Only people with a delivered order at Glow Lab), Customers, Their sales (with money note), Seats used (None), Tier, score, gifts, challenges (None), Customer link (
dir="ltr"); then Copy, Make a new link, Turn link off / on; a note "Glow Lab can copy and share the link. Only PR changes or stops it." - Confirm modal: "Make a new customer link?" with the consequence.
Variants
| Prop | Value | Effect |
|---|---|---|
kind | percent | "Customer rate (%)" |
per_item (the other CommissionKind) | "Customer rate (EGP per item)" | |
linkOn / platformOn | on / off | Pill and the link toggle's label |
States
| State | Trigger |
|---|---|
| Invalid rate | Save with not-a-number or ≤ 0: "Enter a rate above 0." |
| Not below | Save with ≥ creator rate: "It must be below the creator rate (10% of sale)." |
| Saving | saving: Save disabled |
| Error | error: alert under Save |
| Copied | Copy: live region "Customer link copied" (or "Couldn't copy…") for 2.2s; onCopied called |
| New link asked | Make a new link: confirm modal |
Types
Also exported: customerRateIssue(value, creatorRate) → null | 'invalid' | 'not_below'.
CustomerRateSave (onSaveRate): { rate, moveExisting }.
Usage
import { useState } from 'react';
import { CustomerAffiliatesCard } from '@ergasti/bricks';
export 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 in your own form
import { customerRateIssue } from '@ergasti/bricks';
customerRateIssue('6', '10'); // null
customerRateIssue('10', '10'); // 'not_below'
customerRateIssue('0', '10'); // 'invalid'Where it appears
- PR Portal › Affiliate programs › Campaigns › a campaign's page › Customer affiliates card.
- Dashboard screen: PrPrograms (the programs list).
Guidelines
Do
- Pass both rates as decimal strings in the same unit.
- Default "move existing customers" to off; moving them changes what they earn.
Don't
- Don't validate with floats; use
customerRateIssue. - Don't let brands change the link: only PR does (the note says so).
RTL and Arabic
Two columns mirror; the link and rate stay dir="ltr". Arabic words come from the copy (provider key prCustomerCard).
Tokens
--ink-3, --bad (key-value list), card, field, pill and modal tokens.
Accessibility
A labelled section; the rate is a labelled text field (Arabic-Indic digits accepted) with hint and error; the copy result is announced in a live region; buttons are named ("Copy the customer link"); the confirm is a kit Modal.
Found in the source
- Roles in the markup:
alert. - ARIA attributes set:
aria-labelledby,aria-label,aria-live. - Its tests cover: “a save error is announced”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
CustomerAffiliatesSwitch: the platform switch (platformOn).ScheduleCampaignDialog: sets the customer rate for the next campaign with the same rule.CommissionInput: the creator rate field on brand screens.
See also: Button · FormField · Modal · Money · MoneyNote · useBricks · useLanguage · PrStatusPill · AffiliateProgramCard · CampaignChallenges · CampaignChangeRequests · CommissionChangeForm
Source
src/pr/programs/CustomerAffiliatesCard.tsx (line 113) on GitHub.