Skip to Content
BBRICKSv0.7.4
PR PortalChallenges

ChallengeBasicsFields

The challenge builder's step 1, Basics (the v3 mock's P.builder step 1): who it's for (a brand, or "All brands · TRNDR-wide", with the hint that says who pays), the challenge name, the start and end dates side by side, and what creators will read. Controlled: every change calls onChange with the whole value. Put it in a BuilderStepCard.

import { ChallengeBasicsFields } 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.

Pinned to Arabic
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.

prChallengeBuilder
KeyEnglishArabic
forWhoWho it’s forالتحدي لمين
allBrandsAll brands · TRNDR-wideكل البراندات · على مستوى TRNDR
paused{brand} (paused){brand} (متوقف)
chooseChoose a brandاختار براند
brandHintRuns inside this brand’s active campaign. Paid from its wallet.بيشتغل جوه الحملة الشغّالة للبراند ده. بيتدفع من محفظته.
allHintRuns on every brand’s active campaign. TRNDR pays the rewards, not the brands.بيشتغل على الحملة الشغّالة لكل براند. TRNDR بيدفع الجوايز، مش البراندات.
nameChallenge nameاسم التحدي
namePhe.g. Winter top 10مثلاً Winter top 10
startsStartsبيبدأ
endsEndsبيخلص
readWhat creators will readصنّاع المحتوى هيقروا إيه
readPhShort and exciting. Shown in the creator app.قصير ومشوّق. بيظهر في تطبيق صنّاع المحتوى.
typeTypeالنوع
leaderLeaderboardلوحة ترتيب
leaderDThe top creators winالأوائل بيكسبوا
targetTargetهدف
targetDEveryone who hits the goal winsكل اللي يوصل للهدف بيكسب
boostCommission boostزيادة العمولة
boostDEvery delivered sale earns moreكل بيعة بتتسلّم بتكسب أكتر
rankByRank byالترتيب بـ
bySalesDelivered sales ({currency})المبيعات اللي اتسلّمت ({currency})
byOrdersDelivered ordersالطلبات اللي اتسلّمت
winnersNumber of winnersعدد الفايزين
goalGoalالهدف
goalKindGoal countsالهدف بيتحسب بـ
kindOrdersdelivered ordersطلبات اتسلّمت
kindSales{currency} delivered sales{currency} مبيعات اتسلّمت
maxWinnersMax winnersأقصى عدد فايزين
maxHintCaps the budget held from the wallet.بيحدد أقصى ميزانية بتتحجز من المحفظة.
boostLBoostالزيادة
times×{n} commission×{n} عمولة
capCap on the extra commission ({currency})أقصى عمولة زيادة ({currency})
capHintThe boost stops once the extra paid reaches this.الزيادة بتقف لما اللي اتدفع زيادة يوصل للرقم ده.
delivered[object Object][object Object]
leaderNote[object Object][object Object]
boostNote[object Object][object Object]
joinWho can joinمين يقدر يشترك
publicPublicعام
publicDAny approved creator. Non-members send a join request you approveأي صانع محتوى متقبل. اللي مش مشترك بيبعت طلب انضمام إنت بتوافق عليه
affiliates{brand} affiliates onlyالمشتركين في {brand} بس
affiliatesDOnly creators already in the programصنّاع المحتوى اللي في البرنامج بس
everyoneEvery approved creator with a code at any brand that has an active campaign can take part.أي صانع محتوى متقبل عنده كود عند أي براند ليه حملة شغّالة يقدر يشترك.
inviteYou can also invite specific creators after launch. Customer affiliates can’t join challenges or get gifts.تقدر كمان تدعو صنّاع محتوى بعينهم بعد الإطلاق. عملاء الأفلييت مينفعش يدخلوا تحديات ولا ياخدوا هدايا.
rewardLHow winners are paidالفايزين بياخدوا إيه
cashCashكاش
cashDPaid to each winnerبيتدفع لكل فايز
giftGiftهدية
giftDFrom confirmed gift stock onlyمن مخزون الهدايا المتأكد بس
perWinnerPer winner ({currency})لكل فايز ({currency})
paidWhenWinners are paid:الفايزين بياخدوا فلوسهم:
boostReward[object Object][object Object]
boostExtraextra.زيادة.
issue.brandChoose who it’s for.اختار التحدي لمين.
issue.nameAdd a name.اكتب اسم.
issue.startsPick a start date.اختار تاريخ البداية.
issue.endsPick an end date.اختار تاريخ النهاية.
issue.orderIt must end after it starts.لازم يخلص بعد ما يبدأ.
issue.wholeEnter a whole number, 1 or more.اكتب رقم صحيح، 1 أو أكتر.
issue.amountEnter an amount above 0 (up to 2 decimals).اكتب مبلغ أكبر من صفر (لحد رقمين بعد العلامة).
issue.giftIdChoose a gift.اختار هدية.
issue.requiredRequired.لازم.

Design guidance

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

The challenge builder's step 1, Basics: who it's for (a brand or "All brands · TRNDR-wide"), the challenge name, the start and end dates, and what creators will read; put it in a BuilderStepCard.

ChallengeBasicsFields is step 1 of the PR v3 mock's P.builder, which the design system used to compose by hand from .fields. The brand select's hint says who pays: "Runs inside this brand’s active campaign. Paid from its wallet." for a brand, "Runs on every brand’s active campaign. TRNDR pays the rewards, not the brands." for TRNDR-wide (value 'all'). It is controlled and generic over the draft: pass the whole ChallengeDraft (from defaultChallengeDraft) and it changes only brand, name, starts, ends and description, passing the rest through onChange.

Anatomy

  1. Who it’s for: a <select>: "All brands · TRNDR-wide" first (with trndrWide), then brands in order; a paused one reads "Kemet Home (paused)". An unknown brand shows a disabled "Choose a brand". The hint below (with the C2 decision tag when TRNDR-wide and tags are shown).
  2. Challenge name: a text input, placeholder "e.g. Winter top 10".
  3. Starts / Ends: two native date inputs side by side (.kit-pr-f2, one column under 480px); Starts carries the T6 tag; Ends' min is the start.
  4. What creators will read: a textarea, placeholder "Short and exciting. Shown in the creator app."; the last field sits on the card's footer rule.

Variants

PropValueEffectWhen to use
trndrWidetrue (default)"All brands · TRNDR-wide" offered firstPR can run platform-wide challenges
falseBrands onlyA brand-scoped builder
validatefalse (default)No built-in messagesThe mock: the summary lists gaps
truechallengeIssues messages under the fieldsShow problems in place (e.g. before launch)

States

StateTrigger
Brand chosenvalue.brand is a brand id: the "Paid from its wallet" hint
TRNDR-widevalue.brand === 'all': the "TRNDR pays" hint (+ C2 tag)
Unknown brandvalue.brand not in brands (e.g. ''): "Choose a brand" placeholder
Field errorsvalidate: "Choose who it’s for.", "Add a name.", "Pick a start date.", "Pick an end date.", "It must end after it starts."
Server errorserrors={{ name: 'That name is taken.' }}: shown under the field, over the built-in checks
Decision tagsinside a DecisionTagsProvider visible: C2 and T6 tags, with questions from decisions

Usage

import { useState } from 'react';
import { BuilderStepCard, ChallengeBasicsFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';

const brands = [{ id: 'glow', name: 'Glow Lab' }, { id: 'nile', name: 'Nile Threads' }, { id: 'kemet', name: 'Kemet Home', paused: true }];

export function BasicsStep() {
  const [draft, setDraft] = useState<ChallengeDraft>({ ...defaultChallengeDraft('glow'), starts: '2026-12-01', ends: '2026-12-31' });
  return (
    <BuilderStepCard title="Basics" step={1} onContinue={() => {}}>
      <ChallengeBasicsFields value={draft} onChange={(next) => setDraft(next)} brands={brands} />
    </BuilderStepCard>
  );
}
// Showing the checks and a server message in place
import { useState } from 'react';
import { ChallengeBasicsFields, defaultChallengeDraft, type ChallengeDraft } from '@ergasti/bricks';

export function BasicsChecked() {
  const [draft, setDraft] = useState<ChallengeDraft>({ ...defaultChallengeDraft('glow'), name: 'Winter top 10', starts: '2026-12-10', ends: '2026-12-01' });
  return (
    <ChallengeBasicsFields value={draft} onChange={(next) => setDraft(next)} brands={[{ id: 'glow', name: 'Glow Lab' }]} validate
      errors={{ name: 'A challenge with this name is already live.' }} />
  );
}

Where it appears

  • PR Portal › Affiliate programs › Challenges › New challenge › step 1, Basics (the mock's P.builder, st===1). Screen: PR · Challenge builder.

Guidelines

Do

  • Keep one ChallengeDraft state for all four steps and pass it whole.
  • Mark paused brands with paused: true rather than hiding them.
  • Pass decisions so the C2 / T6 tags carry their questions.

Don't

  • Don't format the dates: starts / ends are YYYY-MM-DD from the native input.
  • Don't turn on validate on first paint of a new draft; empty fields would all shout.
  • Don't add a separate "who pays" line; the select's hint says it.

RTL and Arabic

Labels, the date pair and hints mirror. The name and description are dir="auto". Arabic: "التحدي لمين", "كل البراندات · على مستوى TRNDR", "{brand} (متوقف)", "اسم التحدي", "بيبدأ" / "بيخلص", "صنّاع المحتوى هيقروا إيه". Override with labels or labels.prChallengeBuilder (shared by all three step components).

Tokens

--line, --card, --ink, --ink-3, --rasp, --bad, --field-h, --field-radius, --focus-ring-field, --kit-chevron (FormField controls), --sky, --sky-ink (decision tags).

Accessibility

  • Every control is a FormField with a label; errors are tied to their field.
  • Native <select> and type="date" inputs keep the platform's keyboard and pickers.
  • Decision tags read "Open decision C2" and their question to screen readers.

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.

See also: FormField · useLanguage · useDecisionTagsVisible · PageGrid · Stepper · ChallengeSummary · BrandRequestCard · ChallengeGiftPicker

Source

src/pr/challenges/ChallengeBasicsFields.tsx (line 34) on GitHub.

On this page