Skip to Content
BBRICKSv0.7.4
PR PortalCampaigns

CustomerAffiliatesSwitch

The Affiliate programs page's platform switch (the v3 mock's custSwitch / custToggle): an icon square, "Customer affiliates · all brands" with what it does, an On / Off pill and "Turn off" / "Turn on". Turning off asks first (a confirm dialog with the raspberry "Turn off for every brand"); while off, a red banner under the card says what is refused. A labelled section; the pill is the state, the button the action.

import { CustomerAffiliatesSwitch } from '@ergasti/bricks';

Examples

The platform switch

On shows "Turn off", which asks before it stops every brand's customer link; off shows a red banner.

Code
import { useState } from 'react';
import { CustomerAffiliatesSwitch } from '@ergasti/bricks';

function Switch() {
  const [on, setOn] = useState(true);
  return <CustomerAffiliatesSwitch on={on} onTurnOff={() => setOn(false)} onTurnOn={() => setOn(true)} />;
}

A switch that failed to save

error with onRetry: a red alert with Try again under the card.

Code (not run)
import { CustomerAffiliatesSwitch } from '@ergasti/bricks';

function Failed() {
  return <CustomerAffiliatesSwitch on onTurnOff={() => {}} onTurnOn={() => {}} error onRetry={() => {}} />;
}

Props

Prop

Type

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prCustomerSwitch, or with the component's own prop where it has one. A {name} is a value the component fills in.

prCustomerSwitch
KeyEnglishArabic
titleCustomer affiliates · all brandsأفلييت العملاء · كل البراندات
bodyPast customers with a delivered order join a brand with their phone and sell with their own code at a lower rate. Turning this off stops every customer link and sign-up, for every brand.العملاء اللي عندهم طلب اتسلّم بيشتركوا في البراند برقم موبايلهم وبيبيعوا بكود خاص بيهم بعمولة أقل. لو قفلت ده، كل لينكات العملاء والتسجيل بيقفوا، لكل البراندات.
turnOffTurn offاقفله
turnOnTurn onشغّله
confirmTitleTurn off customer affiliates?تقفل أفلييت العملاء؟
confirmBodyEvery brand’s customer link and the “I bought from this brand” sign-up stop straight away. Customers who already joined keep their codes and keep earning.لينك العملاء بتاع كل براند وتسجيل «اشتريت من البراند ده» بيقفوا على طول. العملاء اللي اشتركوا قبل كده بيفضل معاهم الكود وبيفضلوا يكسبوا.
cancelCancelإلغاء
confirmTurn off for every brandاقفله لكل البراندات
offBannerCustomer affiliates are off. Customer links and “I bought from this brand” sign-ups are refused for every brand. Existing customers keep selling.أفلييت العملاء مقفول. لينكات العملاء وتسجيل «اشتريت من البراند ده» مرفوضين لكل البراندات. العملاء الموجودين بيكمّلوا بيع.
errorCouldn’t change the switch.مقدرناش نغيّر الإعداد ده.
retryTry againجرّب تاني

Design guidance

How the BRICKS design system uses CustomerAffiliatesSwitch. Written in docs/content/components/CustomerAffiliatesSwitch.md; the props above are read from the code, which wins where the two disagree.

The Affiliate programs page's platform-wide switch for customer affiliates, with a confirmation before turning it off and a red banner while it is off; use it at the top of the Campaigns tab.

CustomerAffiliatesSwitch is the v3 mock's custSwitch / custToggle. Customer affiliates are past customers with a delivered order who join a brand with their phone and sell with their own code at a lower rate. Turning the feature off stops every brand's customer link and "I bought from this brand" sign-up at once, so the component asks first ("Turn off for every brand"); turning it on needs no confirmation. Customers who already joined keep their codes either way.

Anatomy

  1. Card: <section class="kit-card kit-pr-cswitch"> labelled by its heading.
  2. Icon square: IconSquare name="creators" tone="lime".
  3. Text: h2 "Customer affiliates · all brands" and a muted line on what it does.
  4. State pill: PrStatusPill switch_on (On, green) or switch_off (Off, red).
  5. Action: "Turn off" (default button) or "Turn on" (ink).
  6. Off banner (when off): a red Banner under the card: "Customer affiliates are off. Customer links and … sign-ups are refused for every brand. Existing customers keep selling."
  7. Confirm modal: "Turn off customer affiliates?" with the consequence, Cancel and raspberry "Turn off for every brand".

Variants

onPillButtonBanner
trueOn (green)Turn off → asks firstnone
falseOff (red)Turn on (ink) → immediatered banner

States

StateTrigger
Asking"Turn off" pressed: confirm modal open
Busybusy: both buttons wait

Usage

import { useState } from 'react';
import { CustomerAffiliatesSwitch } from '@ergasti/bricks';

export function Switch() {
  const [on, setOn] = useState(true);
  return <CustomerAffiliatesSwitch on={on} onTurnOff={() => setOn(false)} onTurnOn={() => setOn(true)} />;
}
// Affiliate programs › Campaigns tab: the switch above the campaigns table
<PillTabs label="Affiliate programs" idPrefix="prog" value={tab} onChange={setTab}>
  <PillTabs.Tab value="campaigns" count={4}>Campaigns</PillTabs.Tab>
  <PillTabs.Tab value="challenges" count={3}>Challenges</PillTabs.Tab>
</PillTabs>
<CustomerAffiliatesSwitch on={platform.customersOn} busy={saving} onTurnOff={() => save(false)} onTurnOn={() => save(true)} />
<DataTable label="Campaigns" rows={campaigns} rowKey={(c) => c.id} columns={campaignColumns('en')} onRowClick={openCampaign} />

Where it appears

  • PR Portal › Affiliate programs › Campaigns, above the table.
  • Dashboard screen: PrPrograms.

Guidelines

Do

  • Reflect the server's state in on only after the save succeeds.
  • Show CustomerAffiliatesCard's "Off for all brands" pill on Brand detail while it is off (platformOn={false}).

Don't

  • Don't skip the confirmation for turning off; it affects every brand.
  • Don't place it on Brand detail: it is platform-wide.

RTL and Arabic

Mirrors. Arabic: "أفلييت العملاء · كل البراندات", "اقفله" / "شغّله", "اقفله لكل البراندات".

Tokens

IconSquare lime tokens, PrStatusPill tones (--ok-bg, --ok, --rasp-50, --bad), card and Banner tokens.

Accessibility

A labelled section; the pill is the state in words, the button the action. The confirm is a kit Modal (focus trap, Escape). The banner is a Banner with an alert icon.

Found in the source

  • ARIA attributes set: aria-labelledby.
  • Its tests cover: “a labelled section with the On pill and Turn off”; “the dialog is reached by keyboard and Escape closes it”.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: Banner · Button · Modal · useLanguage · IconSquare · PrStatusPill · Switch · AffiliateProgramCard · CampaignChallenges · CampaignChangeRequests · CommissionChangeForm

Source

src/pr/programs/CustomerAffiliatesSwitch.tsx (line 76) on GitHub.

On this page