ChallengeAudienceFields
The challenge builder's step 3, Who can join (the v3 mock's P.builder step 3): Public (any approved creator; non-members send a join request PR approves) or "{brand} affiliates only", as two choice cards, then the note that creators can be invited after launch and that customer affiliates can't join challenges or get gifts. A TRNDR-wide challenge has no choice: one sentence says who can take part. Controlled. Put it in a BuilderStepCard.
import { ChallengeAudienceFields } from '@ergasti/bricks';Examples
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>;
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prChallengeBuilder, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
forWho | Who it’s for | التحدي لمين |
allBrands | All brands · TRNDR-wide | كل البراندات · على مستوى TRNDR |
paused | {brand} (paused) | {brand} (متوقف) |
choose | Choose a brand | اختار براند |
brandHint | Runs inside this brand’s active campaign. Paid from its wallet. | بيشتغل جوه الحملة الشغّالة للبراند ده. بيتدفع من محفظته. |
allHint | Runs on every brand’s active campaign. TRNDR pays the rewards, not the brands. | بيشتغل على الحملة الشغّالة لكل براند. TRNDR بيدفع الجوايز، مش البراندات. |
name | Challenge name | اسم التحدي |
namePh | e.g. Winter top 10 | مثلاً Winter top 10 |
starts | Starts | بيبدأ |
ends | Ends | بيخلص |
read | What creators will read | صنّاع المحتوى هيقروا إيه |
readPh | Short and exciting. Shown in the creator app. | قصير ومشوّق. بيظهر في تطبيق صنّاع المحتوى. |
type | Type | النوع |
leader | Leaderboard | لوحة ترتيب |
leaderD | The top creators win | الأوائل بيكسبوا |
target | Target | هدف |
targetD | Everyone who hits the goal wins | كل اللي يوصل للهدف بيكسب |
boost | Commission boost | زيادة العمولة |
boostD | Every delivered sale earns more | كل بيعة بتتسلّم بتكسب أكتر |
rankBy | Rank by | الترتيب بـ |
bySales | Delivered sales ({currency}) | المبيعات اللي اتسلّمت ({currency}) |
byOrders | Delivered orders | الطلبات اللي اتسلّمت |
winners | Number of winners | عدد الفايزين |
goal | Goal | الهدف |
goalKind | Goal counts | الهدف بيتحسب بـ |
kindOrders | delivered orders | طلبات اتسلّمت |
kindSales | {currency} delivered sales | {currency} مبيعات اتسلّمت |
maxWinners | Max winners | أقصى عدد فايزين |
maxHint | Caps the budget held from the wallet. | بيحدد أقصى ميزانية بتتحجز من المحفظة. |
boostL | Boost | الزيادة |
times | ×{n} commission | ×{n} عمولة |
cap | Cap on the extra commission ({currency}) | أقصى عمولة زيادة ({currency}) |
capHint | The boost stops once the extra paid reaches this. | الزيادة بتقف لما اللي اتدفع زيادة يوصل للرقم ده. |
delivered | [object Object] | [object Object] |
leaderNote | [object Object] | [object Object] |
boostNote | [object Object] | [object Object] |
join | Who can join | مين يقدر يشترك |
public | Public | عام |
publicD | Any approved creator. Non-members send a join request you approve | أي صانع محتوى متقبل. اللي مش مشترك بيبعت طلب انضمام إنت بتوافق عليه |
affiliates | {brand} affiliates only | المشتركين في {brand} بس |
affiliatesD | Only creators already in the program | صنّاع المحتوى اللي في البرنامج بس |
everyone | Every approved creator with a code at any brand that has an active campaign can take part. | أي صانع محتوى متقبل عنده كود عند أي براند ليه حملة شغّالة يقدر يشترك. |
invite | You can also invite specific creators after launch. Customer affiliates can’t join challenges or get gifts. | تقدر كمان تدعو صنّاع محتوى بعينهم بعد الإطلاق. عملاء الأفلييت مينفعش يدخلوا تحديات ولا ياخدوا هدايا. |
rewardL | How winners are paid | الفايزين بياخدوا إيه |
cash | Cash | كاش |
cashD | Paid to each winner | بيتدفع لكل فايز |
gift | Gift | هدية |
giftD | From confirmed gift stock only | من مخزون الهدايا المتأكد بس |
perWinner | Per winner ({currency}) | لكل فايز ({currency}) |
paidWhen | Winners are paid: | الفايزين بياخدوا فلوسهم: |
boostReward | [object Object] | [object Object] |
boostExtra | extra. | زيادة. |
issue.brand | Choose who it’s for. | اختار التحدي لمين. |
issue.name | Add a name. | اكتب اسم. |
issue.starts | Pick a start date. | اختار تاريخ البداية. |
issue.ends | Pick an end date. | اختار تاريخ النهاية. |
issue.order | It must end after it starts. | لازم يخلص بعد ما يبدأ. |
issue.whole | Enter a whole number, 1 or more. | اكتب رقم صحيح، 1 أو أكتر. |
issue.amount | Enter an amount above 0 (up to 2 decimals). | اكتب مبلغ أكبر من صفر (لحد رقمين بعد العلامة). |
issue.giftId | Choose a gift. | اختار هدية. |
issue.required | Required. | لازم. |
Design guidance
How the BRICKS design system uses ChallengeAudienceFields. Written in docs/content/components/ChallengeAudienceFields.md; the props above are read from the code, which wins where the two disagree.
The challenge builder's step 3, Who can join: Public or "{brand} affiliates only" as two choice cards, then the note on inviting creators; for a TRNDR-wide challenge, one sentence instead. Put it in a BuilderStepCard.
ChallengeAudienceFields is step 3 of the PR v3 mock's P.builder, which the design system used to compose by hand. Public · "Any approved creator. Non-members send a join request you approve" (sky, globe) and "Glow Lab affiliates only" · "Only creators already in the program" (lilac, lock) set value.audience. Under them: "You can also invite specific creators after launch. Customer affiliates can’t join challenges or get gifts." A TRNDR-wide challenge has no choice: "Every approved creator with a code at any brand that has an active campaign can take part."
Anatomy
- Who can join: a two-column
ChoiceGroup(public,brand); the brand's name is wrapped in<bdi>. - Note (
.kit-pr-bhint--gap, 14px above, 12px muted):noteor the invite / customer-affiliates line, with the S8 and T2 tags when shown. - TRNDR-wide line (
trndrWide): a single paragraph with the C3 tag, replacing 1 and 2.
Variants
| Prop | Value | Look | When to use |
|---|---|---|---|
trndrWide | false (default) | The two cards and the note | A brand challenge |
true | One sentence, no choice | The draft's brand is 'all' | |
value.audience | public | Public card chosen | Open to any approved creator |
brand | Affiliates-only card chosen | Program members only | |
note | node | Replaces the default note | A different invite rule |
States
| State | Trigger |
|---|---|
| Public / Affiliates only | value.audience: the chosen card gets the ink edge |
| TRNDR-wide | trndrWide: no cards |
| Decision tags | inside a DecisionTagsProvider visible: S8, T2 (cards) or C3 (TRNDR-wide), with questions from decisions |
Usage
import { useState } from 'react';
import { BuilderStepCard, ChallengeAudienceFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';
export function WhoCanJoinStep() {
const [draft, setDraft] = useState<ChallengeDraft>(defaultChallengeDraft('glow'));
return (
<BuilderStepCard title="Who can join" step={3} onBack={() => {}} onContinue={() => {}}>
<ChallengeAudienceFields value={draft} onChange={(next) => setDraft(next)} brandName="Glow Lab" trndrWide={draft.brand === 'all'} />
</BuilderStepCard>
);
}// A TRNDR-wide draft: one sentence, with the decision tags on
import { ChallengeAudienceFields, DecisionTagsProvider, defaultChallengeDraft } from '@ergasti/bricks';
export function EveryoneCanJoin() {
return (
<DecisionTagsProvider visible>
<ChallengeAudienceFields value={defaultChallengeDraft('all')} onChange={() => {}} brandName="" trndrWide
decisions={[{ id: 'C3', question: 'Can a brand opt out of a TRNDR-wide challenge?' }]} />
</DecisionTagsProvider>
);
}Where it appears
- PR Portal › Affiliate programs › Challenges › New challenge › step 3, Who can join (the mock's
P.builder,st===3). Screen: PR · Challenge builder (step 3 of the same builder).
Guidelines
Do
- Set
trndrWidefrom the draft (draft.brand === 'all') so step 1 and step 3 agree. - Pass the brand's display name; it is isolated with
<bdi>for mixed scripts. - Add specific invites after launch with
CreatorPickDialog(the note promises it).
Don't
- Don't offer customer affiliates here; they can't join challenges.
- Don't add targeting (tiers, niches, followers) to this step; the mock's step has only the two choices.
RTL and Arabic
The two cards swap sides; icons stay. Arabic: "مين يقدر يشترك", "عام", "المشتركين في {brand} بس", "صنّاع المحتوى اللي في البرنامج بس", and the invite note "تقدر كمان تدعو صنّاع محتوى بعينهم بعد الإطلاق…". Override with labels or labels.prChallengeBuilder.
Tokens
--line, --card, --ink, --ink-3, --color-control-border-hover, --focus-ring (choice cards), --sky, --sky-ink (tags).
Accessibility
ChoiceGroup:role="radiogroup"named "Who can join", one tab stop, arrow keys move and choose, Home / End jump.- The TRNDR-wide sentence is plain text; tags read "Open decision C3" and their question.
Found in the source
- No roles, ARIA attributes or key handling are set in this component's own source; it renders native elements and the components it composes.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
BuilderStepCard: the card around it.ChallengeBasicsFields: where'all'(TRNDR-wide) is chosen.CreatorPickDialog: inviting specific creators after launch.ChoiceGroup: the cards.
See also: useLanguage · useDecisionTagsVisible · ChallengeRewardFields · PageGrid · Stepper · ChallengeSummary · BrandRequestCard · ChallengeGiftPicker
Source
src/pr/challenges/ChallengeAudienceFields.tsx (line 37) on GitHub.