ChangeOwnerDialog
The brand page's "Change PR owner" modal (the PR mock v3's changeOwner): what owning a brand means, a "New owner" select of the PR team starting on the current owner (on "Choose the new owner" when there is none, or they are not in owners), Cancel / Save. Saving the same owner, or nobody, says so instead of calling onSave. On the kit Modal (focus trap, Escape, scrim). Controlled by open; the choice resets each time it opens, before the first paint.
import { ChangeOwnerDialog } 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 prChangeOwner, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
title | Change PR owner | غيّر مسؤول الـ PR |
sub | The owner gets {brand}'s alerts and sees it under My brands. Any PR can change this. | المسؤول بيوصله تنبيهات {brand} وبيلاقيه في براندات بتاعتي. أي حد في الـ PR يقدر يغيّر ده. |
owner | New owner | المسؤول الجديد |
you | {name} (you) | {name} (إنت) |
cancel | Cancel | إلغاء |
save | Save | احفظ |
saving | Saving… | بنحفظ… |
same | {name} already owns this brand. Choose someone else. | {name} مسؤول عن البراند ده أصلاً. اختار حد تاني. |
choose | Choose the new owner | اختار المسؤول الجديد |
chooseErr | Choose who owns this brand. | اختار مين المسؤول عن البراند ده. |
Design guidance
How the BRICKS design system uses ChangeOwnerDialog. Written in docs/content/components/ChangeOwnerDialog.md; the props above are read from the code, which wins where the two disagree.
A modal that hands a brand to another PR person; use it from the brand page's PR owner card ("Change").
ChangeOwnerDialog is the PR v3 mock's changeOwner overlay, which the design system used to compose by hand on Brand detail. It says what owning a brand means ("The owner gets Glow Lab's alerts and sees it under My brands. Any PR can change this."), offers a "New owner" select of the PR team starting on the current owner, and commits with an ink Save. Saving the same owner, or nobody, keeps the dialog open and says why instead of calling onSave. It sits on the kit Modal and resets its choice each time it opens.
Anatomy
- Modal: the kit
Modal(.kit-pr-bdlg): title "Change PR owner", close ×, scrim. - Hint: what owning means, with the brand's name, then
note(an open decision tag) after it. - New owner: a
FormFieldwith a 42px<select>(.kit-pr-reason); the signed-in PR reads "Mona Adel (you)". With no current owner the first option is a disabled "Choose the new owner". - Footer: an error alert (with
error) pushed to the start, Cancel (default), Save (ink).
Variants
ChangeOwnerDialog has no visual variants. What changes is the start of the select:
value | Select starts on | When |
|---|---|---|
An id in owners | That person | The brand has an owner on the team |
null | "Choose the new owner" (disabled placeholder) | Nobody owns the brand yet |
An id not in owners | "Choose the new owner" | The owner has left the team |
States
| State | Trigger |
|---|---|
| Closed | open={false} |
| Open, fresh | open becomes true: the choice and the "tried" flag reset before the first paint |
| Same owner | Save with the current owner still picked: "Mona Adel already owns this brand. Choose someone else.", onSave not called |
| Nobody chosen | Save on the placeholder: "Choose who owns this brand." |
| Busy | busy: Save reads "Saving…" and is disabled |
| Error | error: a role="alert" line at the start of the footer |
| Focus | the select gets a raspberry border and --focus-ring |
Picking another person clears the field error.
Usage
import { useState } from 'react';
import { Card, ChangeOwnerDialog, TextLink } from '@ergasti/bricks';
const team = [{ id: 'mona', name: 'Mona Adel' }, { id: 'farida', name: 'Farida Nabil' }, { id: 'ahmed', name: 'Ahmed Samy' }];
export function PrOwnerCard() {
const [open, setOpen] = useState(false);
const [owner, setOwner] = useState<string | number | null>('mona');
return (
<>
<Card title="PR owner" actions={<TextLink onClick={() => setOpen(true)}>Change</TextLink>}>
<b>{team.find((p) => p.id === owner)?.name ?? 'Nobody yet'}</b>
</Card>
<ChangeOwnerDialog
open={open}
onClose={() => setOpen(false)}
brandName="Glow Lab"
owners={team}
value={owner}
meId="mona"
onSave={(id) => { setOwner(id); setOpen(false); }}
/>
</>
);
}// Saving against the server: keep the dialog open on failure
import { useState } from 'react';
import { ChangeOwnerDialog } from '@ergasti/bricks';
const team = [{ id: 'mona', name: 'Mona Adel' }, { id: 'farida', name: 'Farida Nabil' }];
export function OwnerSave({ open, onClose }: { open: boolean; onClose: () => void }) {
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const save = async (id: string | number) => {
setBusy(true);
setError(null);
try {
await fetch(`/api/brands/glow/owner`, { method: 'PUT', body: JSON.stringify({ owner: id }) });
onClose();
} catch {
setError('We couldn’t change the owner. Try again.');
} finally {
setBusy(false);
}
};
return <ChangeOwnerDialog open={open} onClose={onClose} brandName="Glow Lab" owners={team} value="mona" meId="mona" onSave={save} busy={busy} error={error} />;
}Where it appears
- PR Portal › Brand detail › PR owner card › "Change" (the mock's
changeOwner, tagged T9). Screen: PR · Brand. - Dashboard screen: PrBrand.
Guidelines
Do
- Pass the whole PR team in
owners, in the order PR expects, andmeIdso the signed-in person is marked "(you)". - Pass
value={null}for an unowned brand rather than inventing a placeholder owner. - Close the dialog only once the save succeeds; on failure pass
errorand keep it open.
Don't
- Don't disable Save until the choice changes: the dialog explains "already owns this brand" on press.
- Don't make the commit raspberry: in the PR Portal an ownership change commits in
ink. - Don't use it to reassign creators or tiers; use
TierChangeDialogfor tiers.
RTL and Arabic
The modal and footer mirror; the select's chevron moves to the left. Arabic copy: "غيّر مسؤول الـ PR", "المسؤول الجديد", "{name} (إنت)", "اختار المسؤول الجديد", "إلغاء" / "احفظ", "بنحفظ…". Override words with labels or the provider's labels.prChangeOwner.
Tokens
--line, --card, --ink, --rasp, --radius-md, --focus-ring, --kit-chevron, --min-touch-target (44px footer buttons under 1024px), --dlg-title-fs (Modal).
Accessibility
- Kit Modal:
role="dialog",aria-modal="true", named by the title; focus is trapped, Escape and the scrim close it, focus returns to the opener;inertRef(or the whole page) becomes inert. - The select is a
FormFieldwith a real label ("New owner"); the error is tied to the field. - The footer error is
role="alert".
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
AdjustWalletDialog,BrandFeeDialog: the other Brand detail dialogs, opened fromBrandWalletCard.ReasonDialog: a decision that needs a reason.Modal(kit): any other confirmation.
See also: Button · FormField · useLanguage · BrandAvatar · BrandCell · BrandDetailHeader
Source
src/pr/brand/ChangeOwnerDialog.tsx (line 74) on GitHub.