ChallengeGiftPicker
The challenge builder's gift reward (v3 mock step 4, "From confirmed gift stock only"): a select of the brand's confirmed gifts with the units left (a gift with none left is shown, not choosable), the cost per winner held from the wallet, and a warning when fewer are left than the challenge's winners. With no confirmed stock, it says why a gift challenge can't go live yet and links to the gift stock.
import { ChallengeGiftPicker } from '@ergasti/bricks';Examples
Gift reward
Only the brand's confirmed gift stock can be a challenge's reward: units left, the cost per winner, and a warning when fewer are left than winners.
Code
import { useState } from 'react';
import { ChallengeGiftPicker, type ConfirmedGift } from '@ergasti/bricks';
const stock: ConfirmedGift[] = [
{ id: 'serum', name: 'Serum gift set', cost: '650.00', left: 42 },
{ id: 'lip', name: 'Lip oil bundle', cost: '420.00', left: 0 },
{ id: 'mask', name: 'Mask kit', cost: '300.00', left: 4 },
];
function GiftReward() {
const [gift, setGift] = useState<string | number | null>('serum');
return (
<div style={{ maxWidth: 560 }}>
<ChallengeGiftPicker stock={stock} value={gift} onChange={setGift} brand="Glow Lab" needed={10} onOpenStock={() => {}} money={{ decimals: 'auto' }} />
</div>
);
}No confirmed stock
A gift challenge can't go live until its gifts are counted and confirmed.
Code
import { ChallengeGiftPicker, type ConfirmedGift } from '@ergasti/bricks';
const stock: ConfirmedGift[] = [
{ id: 'serum', name: 'Serum gift set', cost: '650.00', left: 42 },
{ id: 'lip', name: 'Lip oil bundle', cost: '420.00', left: 0 },
{ id: 'mask', name: 'Mask kit', cost: '300.00', left: 4 },
];
function NoStock() {
return <div style={{ maxWidth: 560 }}><ChallengeGiftPicker stock={[]} value={null} onChange={() => {}} brand="Nile Threads" onOpenStock={() => {}} /></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 prChallengeGiftPicker, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
label | Gift | الهدية |
choose | Choose a gift | اختار هدية |
left | {n} left | فاضل {n} |
none | No gifts left | مفيش هدايا فاضلة |
cost | Cost per winner | التكلفة لكل كسبان |
incl | incl. delivery | شامل التوصيل |
short | Only {left} left for {need} winners. Lower the winners or ask the brand to send more. | فاضل {left} بس لـ {need} كسبان. قلّل الكسبانين أو اطلب من البراند يبعت تاني. |
empty | {b} has no confirmed gift stock yet. A challenge with gifts can’t go live until its gifts are counted and confirmed. | {b} معندوش مخزون هدايا متأكد منه لسه. التحدي اللي فيه هدايا مش هيشتغل غير لما هداياه تتعد وتتأكد. |
stock | Gift stock | مخزون الهدايا |
soldOut | {name} has no gifts left. Choose another gift. | {name} مفيش منها هدايا فاضلة. اختار هدية تانية. |
Design guidance
How the BRICKS design system uses ChallengeGiftPicker. Written in docs/content/components/ChallengeGiftPicker.md; the props above are read from the code, which wins where the two disagree.
The challenge builder's gift reward field: a select of the brand's confirmed gifts with units left, the cost per winner held from the wallet, and a warning when fewer are left than the challenge's winners; use it in the builder's Reward step when the reward is a gift.
It is the v3 PR mock's step 4 "From confirmed gift stock only". A gift with none left is listed but not choosable. With no confirmed stock it says why a gift challenge can't go live yet and links to the brand's gift stock.
Anatomy
- Field (
.kit-field.kit-pr-gp): label "Gift". - Select: "Choose a gift" placeholder, then "Serum gift set · 42 left", "Lip oil bundle · No gifts left" (disabled).
- Hint (chosen): "Cost per winner" (
MoneyNoteterm) EGP 650 incl. delivery. - Error lines: shortage ("Only 4 left for 10 winners. Lower the winners or ask the brand to send more.") or sold out, each with "Gift stock →".
- Empty (no usable stock): a status paragraph and the link.
Variants
| Case | Condition | Look |
|---|---|---|
| Chosen | value with units left | Select and cost hint. |
| Short | chosen left < needed | Hint plus red warning. |
| Sold out | value points to a gift with 0 left | aria-invalid, "{name} has no gifts left. Choose another gift." |
| No stock | no gift with units left | Explanation and "Gift stock →" (story NoStock). |
States
As above; focus uses the kit field ring.
Types
ConfirmedGift (stock): { id, name, cost, left }, confirmed units only.
Usage
const stock: ConfirmedGift[] = [
{ id: 'serum', name: 'Serum gift set', cost: '650.00', left: 42 },
{ id: 'lip', name: 'Lip oil bundle', cost: '420.00', left: 0 },
{ id: 'mask', name: 'Mask kit', cost: '300.00', left: 4 },
];
<ChallengeGiftPicker
stock={stock}
value={draft.giftId}
onChange={(id) => setDraft({ ...draft, giftId: id })}
brand="Glow Lab"
needed={draft.winners}
onOpenStock={() => navigate('/gifts?brand=glow')}
money={{ decimals: 'auto' }}
/>Where it appears
- PR Portal › Challenge builder › Reward step (gift). Screens: PR · Challenge builder · Reward, PR · Challenge builder.
Guidelines
Do
- Pass only confirmed units (not a brand's claim).
- Pass
neededso a shortage is caught before launch.
Don't
- Don't hide sold-out gifts; they show why they can't be chosen.
RTL and Arabic
- Field mirrors; the arrow flips. "اختار هدية", "فاضل 42", "مفيش هدايا فاضلة".
Tokens
Kit field tokens; error lines use .kit-field-err (--bad).
Accessibility
- A native
<select>with a<label>; hint and errors inaria-describedby;aria-invalidfor a sold-out choice; the empty explanation isrole="status".
Found in the source
- Roles in the markup:
status. - ARIA attributes set:
aria-hidden,aria-labelledby,aria-invalid,aria-describedby. - Its tests cover: “Arabic: the label and the units left”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
ChallengeSummary: shows the gift and cost in the review.BrandGiftStock: the brand page's stock.GiftShipmentCard: confirming stock.
See also: Money · MoneyNote · useLanguage · PrIcon · BrandRequestCard · BuilderStepCard · ChallengeAudienceFields · ChallengeBasicsFields
Source
src/pr/challenges/ChallengeGiftPicker.tsx (line 67) on GitHub.