BrandFeeDialog
The brand page's TRNDR fee modal (the PR mock v3's editFee): the default for every brand, "Fee for this brand (%)" (0 to 50, up to two decimals, checked exactly), and "Use default (5%)" while the brand has its own fee, then Cancel / Save fee. On the kit Modal (focus trap, Escape, scrim). Controlled by open; the field resets to value each time it opens, before the first paint, follows a new value while untouched, and keeps what was typed.
import { BrandFeeDialog } from '@ergasti/bricks';Examples
Change PR owner
The select starts on the current owner and marks you; saving the same person says so instead of calling onSave. value is null for a brand nobody owns yet (or an id no longer in owners): the select then starts on "Choose the new owner". Controlled by open; the choice resets each time it opens.
Code
import { Button, ChangeOwnerDialog } from '@ergasti/bricks';
import { useState } from 'react';
const PRS = [{ id: 'mona', name: 'Mona Adel' }, { id: 'farida', name: 'Farida Nabil' }, { id: 'ahmed', name: 'Ahmed Samy' }];
function ChangeOwner() {
const [open, setOpen] = useState(false);
const [owner, setOwner] = useState<string | number | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Change</Button>
<small>Owner: {PRS.find((p) => p.id === owner)?.name ?? 'nobody yet'}</small>
<ChangeOwnerDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" owners={PRS} value={owner} meId="mona" onSave={(id) => { setOwner(id); setOpen(false); }} />
</div>
);
}Adjust wallet
An amount that is not 0 with up to two decimals (a minus sign takes money out) and a reason. The field asks for a text keyboard, so a phone shows the minus key. The amount is parsed in cents by parseWalletAdjustment (exported for your own checks: "-390.1" gives "-390.10"; 0, "1.005" and "+-5" give null), so onSave gets an exact 2-dp string; with available the dialog shows what the wallet holds after it. Try 0, 1.005 or −390.10.
Code
import { AdjustWalletDialog, Button, type WalletAdjustment } from '@ergasti/bricks';
import { useState } from 'react';
function AdjustWallet() {
const [open, setOpen] = useState(false);
const [last, setLast] = useState<WalletAdjustment | null>(null);
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Adjust wallet</Button>
<small>{last ? `Saved ${last.amount}: ${last.reason}` : 'Nothing saved yet'}</small>
<AdjustWalletDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" available="43390.00" money={{ decimals: 'auto' }} onSave={(a) => { setLast(a); setOpen(false); }} />
</div>
);
}TRNDR fee
0 to BRAND_FEE_MAX (50) % with up to two decimals, checked by parseBrandFee ("7.5" gives "7.50", "50.01" gives null). "Use default (5%)" shows while the brand has its own fee, and saving an empty field uses the default too; without onUseDefault an empty field is an error. A failed save shows error; busy locks the buttons.
Code
import { BrandFeeDialog, Button } from '@ergasti/bricks';
import { useState } from 'react';
function Fee() {
const [open, setOpen] = useState(false);
const [fee, setFee] = useState<string | null>('7.5');
return (
<div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
<Button onClick={() => setOpen(true)}>Change fee</Button>
<small>Fee: {fee === null ? '5% (default)' : `${fee}%`}</small>
<BrandFeeDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" value={fee} defaultFee="5" onSave={(v) => { setFee(v); setOpen(false); }} onUseDefault={() => { setFee(null); setOpen(false); }} />
</div>
);
}Arabic
Code
import { AdjustWalletDialog, Button } from '@ergasti/bricks';
import { useState } from 'react';
function Arabic() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>عدّل المحفظة</Button>
<AdjustWalletDialog open={open} onClose={() => setOpen(false)} brandName="Glow Lab" available="43390.00" onSave={() => setOpen(false)} language="ar" />
</>
);
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prBrandFee, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
title | TRNDR fee for {brand} | رسوم TRNDR على {brand} |
sub | Default is {fee}% for every brand. Set a different fee for this brand, or clear it to use the default. Applies to orders placed after you save. | الافتراضي {fee}% لكل البراندات. حط رسوم مختلفة للبراند ده، أو امسحها علشان يرجع للافتراضي. بتتطبق على الطلبات اللي تتعمل بعد ما تحفظ. |
subNoDefault | Default is {fee}% for every brand. Set a different fee for this brand. Applies to orders placed after you save. | الافتراضي {fee}% لكل البراندات. حط رسوم مختلفة للبراند ده. بتتطبق على الطلبات اللي تتعمل بعد ما تحفظ. |
fee | Fee for this brand (%) | الرسوم للبراند ده (%) |
placeholder | {fee} (default) | {fee} (الافتراضي) |
hint | 0 to 50, up to two decimals | من 0 لـ 50، لحد رقمين بعد العلامة |
useDefault | Use default ({fee}%) | رجّع الافتراضي ({fee}%) |
cancel | Cancel | إلغاء |
save | Save fee | احفظ الرسوم |
saving | Saving… | بنحفظ… |
err | Fee must be 0–50% with up to two decimals. | الرسوم لازم تكون من 0 لـ 50% ولحد رقمين بعد العلامة. |
Design guidance
How the BRICKS design system uses BrandFeeDialog. Written in docs/content/components/BrandFeeDialog.md; the props above are read from the code, which wins where the two disagree.
A modal that sets one brand's TRNDR fee (0 to 50 %, up to two decimals) or returns it to the platform default; open it from the wallet card's "Change fee".
BrandFeeDialog is the PR v3 mock's editFee overlay on Brand detail ("TRNDR fee for Glow Lab"), which the design system used to compose by hand. The hint states the default and when the change applies ("Default is 5% for every brand. Set a different fee for this brand, or clear it to use the default. Applies to orders placed after you save."). The fee is checked exactly in hundredths (parseBrandFee, exported, with BRAND_FEE_MAX = 50) and onSave gets a 2-dp percent string ("7.50"). While the brand has its own fee a ghost "Use default (5%)" sits at the start of the footer.
Anatomy
- Modal: the kit
Modal(.kit-pr-bdlg): title "TRNDR fee for Glow Lab", the default and timing as its hint, close ×, scrim. - Fee field: "Fee for this brand (%)", hint "0 to 50, up to two decimals", a full-width LTR input (
inputMode="decimal"), placeholder "5 (default)"; starts fromvalue. - Footer: an error alert (with
error), Use default (5%) (ghost, pushed to the start, only whilevalueis not null andonUseDefaultis set), Cancel (default), Save fee (ink).
Variants
| Prop | Value | Look | When to use |
|---|---|---|---|
onUseDefault | set | Hint offers clearing; "Use default" button while the brand has its own fee; saving an empty field resets to the default | Brands may return to the default (the mock) |
| unset | Hint without "or clear it"; no button; an empty field is an error | The fee must always be explicit | |
value | "7.5" | Field starts on the brand's fee | Brand has its own fee |
null | Field empty, placeholder "5 (default)" | Brand uses the default |
States
| State | Trigger |
|---|---|
| Closed | open={false} |
| Open, fresh | open becomes true: the field resets to value before the first paint; while untouched it follows a new value |
| Invalid | Save with a fee outside 0–50 or with more than two decimals: "Fee must be 0–50% with up to two decimals." |
| Cleared | Save on an empty field with onUseDefault: calls onUseDefault, or just closes when the brand already uses the default |
| Busy | busy: all footer buttons disabled, Save reads "Saving…" |
| Error | error: role="alert" line in the footer |
Usage
import { useState } from 'react';
import { BrandFeeDialog, BrandWalletCard } from '@ergasti/bricks';
export function BrandFee() {
const [open, setOpen] = useState(false);
const [fee, setFee] = useState<string | null>(null);
return (
<>
<BrandWalletCard available="43390.00" held="18450.00" balance="61840.00" leftPercent={17} health="ok"
feePercent={fee ?? '5'} feeIsDefault={fee === null} onAdjust={() => {}} onChangeFee={() => setOpen(true)} topUpMethods="card" money={{ decimals: 'auto' }} />
<BrandFeeDialog
open={open}
onClose={() => setOpen(false)}
brandName="Glow Lab"
value={fee}
defaultFee="5"
onSave={(next) => { setFee(next); setOpen(false); }}
onUseDefault={() => { setFee(null); setOpen(false); }}
/>
</>
);
}// No "use default": every brand needs an explicit fee, and saving shows a busy state
import { BrandFeeDialog } from '@ergasti/bricks';
export function FeeSaving() {
return <BrandFeeDialog open onClose={() => {}} brandName="Glow Lab" value={null} defaultFee="5" onSave={() => {}} busy />;
}Where it appears
- PR Portal › Brand detail › Wallet card › "Change fee" (the mock's
editFee). Screen: PR · Brand. - Dashboard screen: PrBrand.
Guidelines
Do
- Pass the platform default as
defaultFeeand the brand's own fee (ornull) asvalue. - Store the 2-dp string from
onSave; reset to the default throughonUseDefault, not by saving "5". - Tell PR in the activity log that the change applies to new orders (the mock's log line).
Don't
- Don't format the fee with a % sign in
valueordefaultFee; the copy adds it. - Don't raise the limit in the UI: 50 is
BRAND_FEE_MAXand the server checks it too. - Don't make Save raspberry: PR Portal commits are
ink.
RTL and Arabic
The modal mirrors and "Use default" moves to the right (it sits at the inline start). The input stays dir="ltr"; Arabic-Indic digits and "٫" parse ("٧٫٥" is "7.50"). Arabic copy: "رسوم TRNDR على {brand}", "الرسوم للبراند ده (%)", "رجّع الافتراضي (5%)", "احفظ الرسوم". Override with labels or labels.prBrandFee.
Tokens
--line, --card, --ink, --rasp, --radius-md, --focus-ring, --min-touch-target, --dlg-title-fs (Modal).
Accessibility
- Kit Modal:
role="dialog",aria-modal="true", named by the title; focus trapped, Escape and scrim close, focus returns to the opener. - The field is a
FormFieldwith label and hint; the error is tied to it. - The footer error is
role="alert"; footer buttons are 44px tall under 1024px.
Found in the source
- Roles in the markup:
alert.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
BrandWalletCard: shows the fee (feePercent,feeIsDefault) and opens this dialog.AdjustWalletDialog,ChangeOwnerDialog: the other Brand detail dialogs.PlatformDefaultRow: the platform default itself, in PR settings, with how many brands override it.
See also: Button · FormField · Modal · useLanguage · BrandAvatar · BrandCell · BrandDetailHeader
Source
src/pr/brand/BrandFeeDialog.tsx (line 83) on GitHub.