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.
| Key | English | Arabic |
|---|---|---|
title | Title | العنوان |
titlePlaceholder | e.g. Lip oil bundle push | مثلاً عرض باكدج الليب أويل |
titleError | Give the challenge a title | اكتب عنوان للتحدي |
gifts | Gifts creators can pick | الهدايا اللي صنّاع المحتوى يقدروا يختاروها |
giftsHint | From the gift list the TRNDR team set up for you | من قايمة الهدايا اللي فريق TRNDR جهّزهالك |
inStock | {n} in stock | {n} في المخزن |
noneLeft | No gifts left | الهدايا خلصت |
noLimit | no stock limit | من غير حد للمخزون |
closedLine | Closed · keep up to {n} or untick | الهدية اتقفلت · سيب لحد {n} أو شيل العلامة |
platformDropped | This request was for a platform that is no longer offered; it now goes to any platform. | الطلب ده كان لمنصة مبقتش متاحة، فبقى لأي منصة. |
changeOnly | Only the end date and gifts can change once a challenge is approved. | بعد ما التحدي يتوافق عليه، تقدر تغيّر تاريخ النهاية والهدايا بس. |
groupGone | A group you deleted | مجموعة اتمسحت |
pickGift | Offer {n} | اعرض {n} |
quantity | Quantity of {n} | كمية {n} |
quantityPlaceholder | Qty | الكمية |
quantityError | Pick 1 to {max} | اختار من 1 لـ {max} |
quantityRequired | Enter how many. | اكتب العدد. |
noGifts | No gift products yet. Ask the TRNDR team to set up your gift list. | لسه مفيش هدايا. اطلب من فريق TRNDR يجهّز قايمة الهدايا. |
who | Who can join | مين يقدر يشترك |
minFollowers | Minimum followers | أقل عدد متابعين |
minFollowersPlaceholder | Minimum followers, e.g. 10,000 | أقل عدد متابعين، مثلاً 10,000 |
platform | Platform | المنصة |
anyPlatform | Any platform | أي منصة |
niche | Niche | المجال |
anyNiche | Any niche | أي مجال |
tier | Tier | المستوى |
anyTier | Any tier | أي مستوى |
group | Group | المجموعة |
anyGroup | Any group | أي مجموعة |
dates | Dates (optional) | المواعيد (اختياري) |
optional | (optional) | (اختياري) |
start | Start date | تاريخ البداية |
end | End date | تاريخ النهاية |
datesHint | Leave empty and TRNDR sets them. | سيبها فاضية وTRNDR هيحددها. |
datesError | The end date is before the start | تاريخ النهاية قبل البداية |
commission | Suggested commission | العمولة المقترحة |
commissionHint | TRNDR confirms the final rate. | TRNDR هيأكد النسبة النهائية. |
notes | Anything else (optional) | أي حاجة تانية (اختياري) |
notesPlaceholder | Goals, products to push, content ideas | أهداف، منتجات عايز تركّز عليها، أفكار محتوى |
cancel | Cancel | إلغاء |
send | Send request | ابعت الطلب |
sending | Sending… | جاري الإرسال… |
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
- Title:
FormField"Title", placeholder "e.g. Lip oil bundle push". - 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.
- Who can join: minimum followers, Platform, Niche, Tier, Group selects ("Any …" first).
- Dates (optional): Start date, End date; "Leave empty and TRNDR sets them."
- Suggested commission:
CommissionInput; hint "TRNDR confirms the final rate." - Anything else (optional): notes textarea, "Goals, products to push, content ideas".
- Error alert and actions: Cancel, rasp "Send request" ("Sending…").
Variants
mode | Behaviour |
|---|---|
'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
| State | Trigger |
|---|---|
| Field errors | submit with problems: "Give the challenge a title", "Pick 1 to 32", "The end date is before the start", rate errors. |
| Server field errors | fieldErrors keys title, starts_at, ends_at, commission…, eligibility…, notes, gift.<id>… / gift_lines.<n>…; other keys show above the buttons. |
| No gifts in stock | left: 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 platform | a sent platform no longer offered: note, sent as any platform. |
| Deleted group | a sent group not in groups: "A group you deleted". |
| Saving | saving: form locked, "Sending…". |
| Server error | error 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 fromChallengeCardandChallengeDetail(BrandMotivation).
Guidelines
Do
- Offer only gifts the TRNDR team set up; pass
leftfrom 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.
Related
See also: FormField · Button · useBricks · useLanguage · BonusCard · BonusDetail
Source
src/blocks/motivation/ChallengeRequestForm.tsx (line 185) on GitHub.