Skip to Content
BBRICKSv0.7.4
Recipes

Brand detail page

One brand in the PR portal: the header with health and actions, view as brand, and tabbed panels for the wallet, challenges and activity.

The brand page is where PR sees one brand: its status, its money, what it runs and what changed. It is a header and three tab panels.

The whole page

BrandDetailHeader (status, wallet health with the day below zero, meta, back crumb and quick actions); "View as brand" swaps in ViewAsBanner; PillTabs with panels for the overview (BrandWalletCard with its AdjustWalletDialog and BrandFeeDialog, the AffiliateProgramCard, CampaignChangeRequests, laid out with PageGrid), the brand's challenges (challengeColumns) and its activity (AuditLogList, or PrEmpty when there is none).

Pinned to TRNDR presetPR theme
Code
import { useState } from 'react';
import { AdjustWalletDialog, AffiliateProgramCard, AuditLogList, BrandDetailHeader, BrandFeeDialog, BrandWalletCard, Button, Card, CampaignChangeRequests, DataTable, PageGrid, PillTabs, PrEmpty, ViewAsBanner, challengeColumns, commissionText, useLanguage, type AuditEntry, type ChallengeRow } from '@ergasti/bricks';
import { changeRequests, prBrands } from './recipes';

const challenges: ChallengeRow[] = [
  { id: 'winter', name: 'Winter top 10', type: 'leader', audience: 'public', brand: prBrands.kemet, status: 'live', dates: '1 Nov – 30 Nov', creators: 64, sales: '254300.00', commission: '25430.00', waiting: 3 },
  { id: 'sprint', name: 'Weekend sprint', type: 'target', audience: 'brand', brand: prBrands.kemet, status: 'upcoming', dates: '6 Dec – 8 Dec', creators: 0, sales: '0.00', commission: '0.00', waiting: 5 },
];

const activity: AuditEntry[] = [
  { id: 1, tone: 'rasp', text: 'Mona changed Kemet Home commission 10% of sale → 12% of sale', detail: 'Brand notified. Applies to new orders.', area: 'programs', actor: { name: 'Mona', seed: 0 }, when: 'Today · 09:30' },
  { id: 2, tone: 'ok', text: 'Ahmed approved Hana Rami into Kemet Home', detail: 'Coupon code created', area: 'approvals', actor: { name: 'Ahmed', seed: 3 }, when: '14 Nov · 12:40' },
];

function Page() {
  const language = useLanguage();
  const [tab, setTab] = useState('overview');
  const [viewAs, setViewAs] = useState(false);
  const [dialog, setDialog] = useState<'adjust' | 'fee' | null>(null);
  const [fee, setFee] = useState<string | null>(null);
  const panel = (value: string) => ({ role: 'tabpanel', id: PillTabs.panelId('brand', value), 'aria-labelledby': PillTabs.tabId('brand', value), hidden: tab !== value });
  return (
    <PageGrid>
      {viewAs ? <ViewAsBanner brandName="Kemet Home" onExit={() => setViewAs(false)} /> : null}
      <BrandDetailHeader
        name="Kemet Home" color={prBrands.kemet.color} status="active" health="negative" healthDay={4}
        meta={['Since 5 Oct 2026', '12% of sale', 'PR owner: Mona']} onBack={() => {}} backLabel="Brands"
        actions={<><Button onClick={() => setViewAs(true)}>View as brand</Button><Button variant="ink">New challenge</Button></>}
      />
      <PillTabs label="Kemet Home" idPrefix="brand" value={tab} onChange={setTab} controls>
        <PillTabs.Tab value="overview">Overview</PillTabs.Tab>
        <PillTabs.Tab value="challenges" count={challenges.length}>Challenges</PillTabs.Tab>
        <PillTabs.Tab value="activity">Activity</PillTabs.Tab>
      </PillTabs>
      <div {...panel('overview')}>
        <PageGrid>
        <PageGrid cols={2} align="start">
          <BrandWalletCard available="-8400.00" held="1200.00" balance="-7200.00" leftPercent={0} health="negative" healthDay={4} feePercent={fee ?? '5'} feeIsDefault={fee === null} onAdjust={() => setDialog('adjust')} onChangeFee={() => setDialog('fee')} />
          <AffiliateProgramCard brandName="Kemet Home" since="Since 5 Oct 2026" commission={commissionText('percent', '12', language)} creatorsCount={57} waiting={2} onEdit={() => {}} onPause={() => {}} onReviewJoins={() => setTab('challenges')} />
        </PageGrid>
        <CampaignChangeRequests brandName="Kemet Home" requests={changeRequests} onApprove={() => {}} onDecline={() => {}} />
        </PageGrid>
      </div>
      <div {...panel('challenges')}>
        <DataTable label="Kemet Home challenges" rows={challenges} rowKey={(r) => r.id} columns={challengeColumns(language, { onOpen: () => {} })} onRowClick={() => {}} />
      </div>
      <div {...panel('activity')}>
        <Card>{activity.length ? <AuditLogList label="Kemet Home activity" entries={activity} /> : <PrEmpty title="No activity yet" text="Changes to this brand show up here." icon="log" tone="sky" />}</Card>
      </div>
      <AdjustWalletDialog open={dialog === 'adjust'} onClose={() => setDialog(null)} brandName="Kemet Home" available="-8400.00" onSave={() => setDialog(null)} />
      <BrandFeeDialog open={dialog === 'fee'} onClose={() => setDialog(null)} brandName="Kemet Home" value={fee} defaultFee="5" onSave={(v) => { setFee(v); setDialog(null); }} onUseDefault={() => { setFee(null); setDialog(null); }} />
    </PageGrid>
  );
}

Steps

  1. Head the page. BrandDetailHeader takes the name and colour, the program status, the wallet health (with healthDay below zero), muted meta lines, the back crumb (onBack, backLabel) and quick actions.
  2. View as the brand. When PR opens the brand's own view, show ViewAsBanner above everything with onExit. To show the brand's page itself, put it in a ReadOnlyFrame: nothing in it can be used.
  3. Split the rest into tabs. PillTabs with controls points each tab at its panel; give each panel role="tabpanel", id={PillTabs.panelId(prefix, value)} and aria-labelledby={PillTabs.tabId(prefix, value)}, and hide the ones not selected.
  4. Overview. A PageGrid stacks the panel, with a cols={2} row on top. BrandWalletCard shows available, held and balance, the health bar and the TRNDR fee; its onAdjust opens AdjustWalletDialog (a signed amount and a reason, parsed in cents) and onChangeFee opens BrandFeeDialog (0 to 50 %, or back to the default). AffiliateProgramCard holds the program: the commission (in words from commissionText), the creators, the join requests waiting, and Edit / Pause (asking for a reason first) / Review. CampaignChangeRequests lists what the brand asked for.
  5. Challenges. A DataTable with challengeColumns, filtered to the brand.
  6. Activity. AuditLogList with the brand's entries, or PrEmpty when there are none (the list itself draws only its entries).

Related: Campaign change requests, Compose a PR portal page.

On this page