Skip to Content
BBRICKSv0.7.4
PR PortalBrands

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.

Pinned to TRNDR preset
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

Pinned to ArabicTRNDR preset
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.

prChangeOwner
KeyEnglishArabic
titleChange PR ownerغيّر مسؤول الـ PR
subThe owner gets {brand}'s alerts and sees it under My brands. Any PR can change this.المسؤول بيوصله تنبيهات {brand} وبيلاقيه في براندات بتاعتي. أي حد في الـ PR يقدر يغيّر ده.
ownerNew ownerالمسؤول الجديد
you{name} (you){name} (إنت)
cancelCancelإلغاء
saveSaveاحفظ
savingSaving…بنحفظ…
same{name} already owns this brand. Choose someone else.{name} مسؤول عن البراند ده أصلاً. اختار حد تاني.
chooseChoose the new ownerاختار المسؤول الجديد
chooseErrChoose 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

  1. Modal: the kit Modal (.kit-pr-bdlg): title "Change PR owner", close ×, scrim.
  2. Hint: what owning means, with the brand's name, then note (an open decision tag) after it.
  3. New owner: a FormField with 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".
  4. 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:

valueSelect starts onWhen
An id in ownersThat personThe 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

StateTrigger
Closedopen={false}
Open, freshopen becomes true: the choice and the "tried" flag reset before the first paint
Same ownerSave with the current owner still picked: "Mona Adel already owns this brand. Choose someone else.", onSave not called
Nobody chosenSave on the placeholder: "Choose who owns this brand."
Busybusy: Save reads "Saving…" and is disabled
Errorerror: a role="alert" line at the start of the footer
Focusthe 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, and meId so 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 error and 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 TierChangeDialog for 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 FormField with 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.

See also: Button · FormField · useLanguage · BrandAvatar · BrandCell · BrandDetailHeader

Source

src/pr/brand/ChangeOwnerDialog.tsx (line 74) on GitHub.

On this page