Skip to Content
BBRICKSv0.7.4
BlocksMotivation

ChallengeRequestForm

The "Request a challenge" modal body: a title, the gifts creators may pick (only what is in stock, with a quantity up to it), who can join (minimum followers, platform, niche, tier, group), optional dates, a suggested commission and notes. Title required; quantities 1–stock; the end not before the start; a suggested rate 1–100 % or above 0. Errors sit on their field and focus moves to the first.

import { ChallengeRequestForm } from '@ergasti/bricks';

Examples

Request a challenge

Name, gifts with quantities (checked against what is left), who can join, dates, the commission and notes. The form reports a ChallengeRequestValue; validation messages come from the component.

Code
import { ChallengeRequestForm } from '@ergasti/bricks';
import { blocksData } from './sample-data';

function Request() {
  return (
    <div style={{ maxWidth: 660 }}>
      <ChallengeRequestForm
        gifts={blocksData.GIFT_STOCK.map((g) => ({ id: g.id, name: g.name, left: g.total - g.picked }))}
        niches={[['beauty', 'Beauty'], ['fashion', 'Fashion']]}
        tiers={[['rising', 'Rising'], ['established', 'Established'], ['elite', 'Elite']]}
        groups={blocksData.GROUPS.map((g) => [g.id, g.name] as const)}
        onSubmit={() => {}}
        onCancel={() => {}}
      />
    </div>
  );
}

Edit and resend, while sending, after a failure

initial starts from the sent request ("Edit and resend"); platforms replaces the platform list; currency names the per-item unit. saving locks the form and error shows the server's answer above the buttons.

Code
import { ChallengeRequestForm } from '@ergasti/bricks';
import { blocksData } from './sample-data';

function EditSaving() {
  return (
    <div style={{ display: 'grid', gap: 16, maxWidth: 660 }}>
      <ChallengeRequestForm
        gifts={blocksData.GIFT_STOCK.map((g) => ({ id: g.id, name: g.name, left: g.total - g.picked }))}
        platforms={[['instagram', 'Instagram'], ['tiktok', 'TikTok']]}
        initial={{ title: 'Winter glow launch', minFollowers: '5000', platform: 'tiktok', start: '2026-12-01', end: '2026-12-31', commission: { kind: 'per_item', value: '40' }, notes: 'Focus on the new serum.' }}
        currency="EGP" saving
        onSubmit={() => {}} onCancel={() => {}}
      />
      <ChallengeRequestForm
        gifts={[]} initial={{ title: 'Winter glow launch' }}
        error="The request could not be sent: the TRNDR team closed requests for December."
        commissionLabels={{ value: 'Suggested commission' }}
        onSubmit={() => {}} onCancel={() => {}}
      />
    </div>
  );
}

Change an approved challenge

mode="change" locks the title, start date and commission (only a later end and gift lines apply) and says so. A gift with left: null has no stock limit; a closed line can keep up to left or be unticked; a sent group no longer in groups stays as "A group you deleted". fieldErrors puts the server's 422 on each field.

Code
import { ChallengeRequestForm } from '@ergasti/bricks';

function ChangeAndServerErrors() {
  return (
    <div style={{ maxWidth: 620 }}>
      <ChallengeRequestForm mode="change"
        initial={{ title: 'Winter glow launch', start: '2026-11-01', end: '2026-11-30', commission: { kind: 'percent', value: '15' }, gifts: [{ id: 2, quantity: 5 }], group: '9' }}
        gifts={[{ id: 1, name: 'Tote bag', left: null }, { id: 2, name: 'Serum', left: 3, closed: true }, { id: 3, name: 'Mask', left: 0 }]}
        groups={[['3', 'Top sellers']]} fieldErrors={{ ends_at: 'The end must be after the current end.' }}
        onSubmit={() => {}} onCancel={() => {}} />
    </div>
  );
}

A hint that follows the kind

commissionHint as a function gets the chosen kind, so a per-item caveat shows only when "EGP per item" is picked. A string or nothing works as before.

Code
import { ChallengeRequestForm } from '@ergasti/bricks';

function HintByKind() {
  return (
    <div style={{ maxWidth: 620 }}>
      <ChallengeRequestForm gifts={[]} onSubmit={() => {}} onCancel={() => {}}
        commissionHint={(kind) => (kind === 'per_item' ? 'Per item is a suggestion: TRNDR sets the final terms.' : 'TRNDR confirms the final rate.')} />
    </div>
  );
}

The server's limits

limits sets the bounds the form checks before it sends: titleMax (default 120), notesMax (default 2000) and the suggested rate's percent / perItem range, which the error then names ("between 0.01% and 50%"). Pass them when your API's rules differ from the console's; leave them out to keep the defaults. mode="create" is the default (the new-request form, as GroupForm names it). Press Send request to see a 60% rate refused.

Code
import { ChallengeRequestForm } from '@ergasti/bricks';

function ServerLimits() {
  return (
    <div style={{ maxWidth: 620 }}>
      <ChallengeRequestForm mode="create" gifts={[]} onSubmit={() => {}} onCancel={() => {}}
        initial={{ title: 'Ramadan glow', commission: { kind: 'percent', value: '60' } }}
        limits={{ titleMax: 60, notesMax: 500, percent: { min: '0.01', max: 50 }, perItem: { min: '0.01', max: 10000 } }} />
    </div>
  );
}

Props

Prop

Type

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key challengeRequestForm, or with the component's own prop where it has one. A {name} is a value the component fills in.

challengeRequestForm
KeyEnglishArabic
titleTitleالعنوان
titlePlaceholdere.g. Lip oil bundle pushمثلاً عرض باكدج الليب أويل
titleErrorGive the challenge a titleاكتب عنوان للتحدي
giftsGifts creators can pickالهدايا اللي صنّاع المحتوى يقدروا يختاروها
giftsHintFrom the gift list the TRNDR team set up for youمن قايمة الهدايا اللي فريق TRNDR جهّزهالك
inStock{n} in stock{n} في المخزن
noneLeftNo gifts leftالهدايا خلصت
noLimitno stock limitمن غير حد للمخزون
closedLineClosed · keep up to {n} or untickالهدية اتقفلت · سيب لحد {n} أو شيل العلامة
platformDroppedThis request was for a platform that is no longer offered; it now goes to any platform.الطلب ده كان لمنصة مبقتش متاحة، فبقى لأي منصة.
changeOnlyOnly the end date and gifts can change once a challenge is approved.بعد ما التحدي يتوافق عليه، تقدر تغيّر تاريخ النهاية والهدايا بس.
groupGoneA group you deletedمجموعة اتمسحت
pickGiftOffer {n}اعرض {n}
quantityQuantity of {n}كمية {n}
quantityPlaceholderQtyالكمية
quantityErrorPick 1 to {max}اختار من 1 لـ {max}
quantityRequiredEnter how many.اكتب العدد.
noGiftsNo gift products yet. Ask the TRNDR team to set up your gift list.لسه مفيش هدايا. اطلب من فريق TRNDR يجهّز قايمة الهدايا.
whoWho can joinمين يقدر يشترك
minFollowersMinimum followersأقل عدد متابعين
minFollowersPlaceholderMinimum followers, e.g. 10,000أقل عدد متابعين، مثلاً 10,000
platformPlatformالمنصة
anyPlatformAny platformأي منصة
nicheNicheالمجال
anyNicheAny nicheأي مجال
tierTierالمستوى
anyTierAny tierأي مستوى
groupGroupالمجموعة
anyGroupAny groupأي مجموعة
datesDates (optional)المواعيد (اختياري)
optional(optional)(اختياري)
startStart dateتاريخ البداية
endEnd dateتاريخ النهاية
datesHintLeave empty and TRNDR sets them.سيبها فاضية وTRNDR هيحددها.
datesErrorThe end date is before the startتاريخ النهاية قبل البداية
commissionSuggested commissionالعمولة المقترحة
commissionHintTRNDR confirms the final rate.TRNDR هيأكد النسبة النهائية.
notesAnything else (optional)أي حاجة تانية (اختياري)
notesPlaceholderGoals, products to push, content ideasأهداف، منتجات عايز تركّز عليها، أفكار محتوى
cancelCancelإلغاء
sendSend requestابعت الطلب
sendingSending…جاري الإرسال…

Design guidance

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

The "Request a challenge" modal body: a title, the gifts creators may pick (in stock, with a quantity), who can join (minimum followers, platform, niche, tier, group), optional dates, a suggested commission and notes, with Cancel / Send request.

It is the mock's openRequest() modal on Brand › Motivation ("+ Request a challenge"). The brand proposes; the TRNDR team reviews, may adjust it and switches it on. The same form serves "Edit request" / "Edit and resend" (initial) and, with mode="change", a change to an approved challenge (title, start and commission locked; only a later end and gift lines apply). It validates on submit (title required up to 120 characters, quantities 1–stock, end not before start, a suggested rate 0.01–100 % or above 0 per item), puts errors on their fields and focuses the first; the server's 422 errors land on the same fields.

Anatomy

  1. Title: FormField "Title", placeholder "e.g. Lip oil bundle push".
  2. Gifts: "Gifts creators can pick" / "From the gift list the TRNDR team set up for you": a checkbox per gift ("Offer <name>") with "32 in stock" / "No gifts left" / "no stock limit", and a quantity field when ticked; "No gift products yet…" when none.
  3. Who can join: minimum followers, Platform, Niche, Tier, Group selects ("Any …" first).
  4. Dates (optional): Start date, End date; "Leave empty and TRNDR sets them."
  5. Suggested commission: CommissionInput; hint "TRNDR confirms the final rate."
  6. Anything else (optional): notes textarea, "Goals, products to push, content ideas".
  7. Error alert and actions: Cancel, rasp "Send request" ("Sending…").

Variants

modeBehaviour
'create' (default; 'new' is an alias)New request, or edit / resend with initial.
'change'Approved challenge: title, start, commission locked with "Only the end date and gifts can change once a challenge is approved."

Other options: platforms replaces the provider's list; commissionHint (string or per-kind function); limits (titleMax, notesMax, percent, perItem); currency.

States

StateTrigger
Field errorssubmit with problems: "Give the challenge a title", "Pick 1 to 32", "The end date is before the start", rate errors.
Server field errorsfieldErrors keys title, starts_at, ends_at, commission…, eligibility…, notes, gift.<id>… / gift_lines.<n>…; other keys show above the buttons.
No gifts in stockleft: 0 lines are disabled ("No gifts left"); gifts=[] shows the "No gift products yet" line.
Closed gift (change)closed: true: "Closed · keep up to 3 or untick".
Dropped platforma sent platform no longer offered: note, sent as any platform.
Deleted groupa sent group not in groups: "A group you deleted".
Savingsaving: form locked, "Sending…".
Server errorerror alert.

Types

ChallengeRequestValue: { title, gifts: { id, quantity }[], minFollowers, platform, niche, tier, group, start, end, commission: { kind, value }, notes } (strings; empty = any / unset).

RequestGift (gifts): { id, name, left: number | null, closed? }.

Usage

// Brand › Motivation › "+ Request a challenge"
<Modal open title="Request a challenge" wide onClose={close}>
  <ChallengeRequestForm
    gifts={stock.map((g) => ({ id: g.id, name: g.name, left: g.total - g.picked }))}
    niches={[['beauty', 'Beauty'], ['fashion', 'Fashion']]}
    tiers={[['rising', 'Rising'], ['established', 'Established'], ['elite', 'Elite']]}
    groups={groups.map((g) => [g.id, g.name] as const)}
    onSubmit={(v) => send.run(v)} onCancel={close}
    saving={send.pending} error={send.error?.message} fieldErrors={send.error?.fields} />
</Modal>
// "Edit and resend" a rejected request
<ChallengeRequestForm gifts={gifts} platforms={[['instagram', 'Instagram'], ['tiktok', 'TikTok']]}
  initial={{ title: 'Winter glow launch', minFollowers: '5000', platform: 'tiktok', start: '2026-12-01', end: '2026-12-31',
    commission: { kind: 'per_item', value: '40' }, notes: 'Focus on the new serum.' }}
  onSubmit={resend} onCancel={close} />
// Change an approved challenge
<ChallengeRequestForm mode="change" gifts={[{ id: 3, name: 'Glow serum 30 ml', left: 3, closed: true }]}
  initial={approved} onSubmit={requestChange} onCancel={close} />

Where it appears

  • Brand › Motivation › Request a challenge modal (openRequest()), and Edit request / Edit and resend / Request a change from ChallengeCard and ChallengeDetail (BrandMotivation).

Guidelines

Do

  • Offer only gifts the TRNDR team set up; pass left from the server.
  • Use mode="change" for approved challenges so locked fields are explained.

Don't

  • Don't make dates required; TRNDR sets them when empty.

RTL and Arabic

  • Mirrors; numbers typed in Arabic-Indic digits are read as digits. Arabic: "مين يقدر يشترك", "العمولة المقترحة", "ابعت الطلب", "سيبها فاضية وTRNDR هيحددها."

Tokens

--line, --card, --rasp, --focus-ring-field, --bad, --ink-3, --rasp-50.

Accessibility

  • Every control is labelled; groups use fieldsets; errors are tied to fields and focus moves to the first invalid one.
  • "(optional)" is part of the label text, drawn muted.

Found in the source

  • Roles in the markup: alert.
  • ARIA attributes set: aria-invalid, aria-label, aria-describedby.
  • It moves focus in code.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: FormField · Button · useBricks · useLanguage · BonusCard · BonusDetail

Source

src/blocks/motivation/ChallengeRequestForm.tsx (line 185) on GitHub.

On this page