Skip to Content
BBRICKSv0.7.4
BlocksMessages

MessageHistoryItem

One sent message, read-only: its name, channel and status, the date, who sent it ("Sent by TRNDR on your behalf" or by the brand), the text in the page's language (the other language when that one is empty), who it went to, and how many it was sent to and delivered. An article named by the message and its date.

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

Examples

One message

The name, channel, status, when it was sent, who sent it, the audience and how many it reached; the body is shown in the page's language when the message has it.

Code
import { MessageHistoryItem, type BrandMessage } from '@ergasti/bricks';

const messages: BrandMessage[] = [
  { id: 1, name: 'Winter glow is live', body_en: 'Our Winter glow challenge starts today. Pick your gift in the app.', body_ar: 'تحدي Winter glow بدأ النهارده. اختار هديتك من التطبيق.', channel: 'whatsapp', status: 'sent', sent_at: '2026-11-12T10:00:00+02:00', sent_by: 'trndr_on_behalf', audience: { kind: 'all' }, recipients: 304, delivered: 298 },
  { id: 2, name: 'Top sellers bonus', body_en: 'You are in the top sellers group: the bonus is on.', body_ar: null, channel: 'sms', status: 'sent', sent_at: '2026-11-08T12:30:00+02:00', sent_by: 'brand', audience: { kind: 'group', groups: [{ id: 'g1', name: 'Top sellers' }] }, recipients: 4, delivered: 4 },
  { id: 3, name: 'Elite creators', body_en: 'A note for our Elite tier.', body_ar: null, channel: 'whatsapp', status: 'queued', sent_at: null, sent_by: 'trndr_on_behalf', audience: { kind: 'tier', tiers: ['elite'] }, recipients: null, delivered: null },
];

function Item() {
  return <div style={{ maxWidth: 620 }}><MessageHistoryItem message={messages[0]} /></div>;
}

History with a filter

A list of messages with a "sent by" filter, a pager slot, and loading, error and empty states.

Code
import { MessageHistoryList, type BrandMessage } from '@ergasti/bricks';
import { useState } from 'react';
import type { MessageSentByFilter } from '@ergasti/bricks';

const messages: BrandMessage[] = [
  { id: 1, name: 'Winter glow is live', body_en: 'Our Winter glow challenge starts today. Pick your gift in the app.', body_ar: 'تحدي Winter glow بدأ النهارده. اختار هديتك من التطبيق.', channel: 'whatsapp', status: 'sent', sent_at: '2026-11-12T10:00:00+02:00', sent_by: 'trndr_on_behalf', audience: { kind: 'all' }, recipients: 304, delivered: 298 },
  { id: 2, name: 'Top sellers bonus', body_en: 'You are in the top sellers group: the bonus is on.', body_ar: null, channel: 'sms', status: 'sent', sent_at: '2026-11-08T12:30:00+02:00', sent_by: 'brand', audience: { kind: 'group', groups: [{ id: 'g1', name: 'Top sellers' }] }, recipients: 4, delivered: 4 },
  { id: 3, name: 'Elite creators', body_en: 'A note for our Elite tier.', body_ar: null, channel: 'whatsapp', status: 'queued', sent_at: null, sent_by: 'trndr_on_behalf', audience: { kind: 'tier', tiers: ['elite'] }, recipients: null, delivered: null },
];

function History() {
  const [sentBy, setSentBy] = useState<MessageSentByFilter>('all');
  const shown = messages.filter((m) => sentBy === 'all' || m.sent_by === sentBy);
  return <div style={{ maxWidth: 620 }}><MessageHistoryList messages={shown} sentBy={{ value: sentBy, onChange: setSentBy }} /></div>;
}

Messages page

The history plus a way to ask TRNDR to send something (onContact or contactUrl) and a slot for the automatic messages.

Code
import { MessagesPanel, type BrandMessage } from '@ergasti/bricks';

const messages: BrandMessage[] = [
  { id: 1, name: 'Winter glow is live', body_en: 'Our Winter glow challenge starts today. Pick your gift in the app.', body_ar: 'تحدي Winter glow بدأ النهارده. اختار هديتك من التطبيق.', channel: 'whatsapp', status: 'sent', sent_at: '2026-11-12T10:00:00+02:00', sent_by: 'trndr_on_behalf', audience: { kind: 'all' }, recipients: 304, delivered: 298 },
  { id: 2, name: 'Top sellers bonus', body_en: 'You are in the top sellers group: the bonus is on.', body_ar: null, channel: 'sms', status: 'sent', sent_at: '2026-11-08T12:30:00+02:00', sent_by: 'brand', audience: { kind: 'group', groups: [{ id: 'g1', name: 'Top sellers' }] }, recipients: 4, delivered: 4 },
  { id: 3, name: 'Elite creators', body_en: 'A note for our Elite tier.', body_ar: null, channel: 'whatsapp', status: 'queued', sent_at: null, sent_by: 'trndr_on_behalf', audience: { kind: 'tier', tiers: ['elite'] }, recipients: null, delivered: null },
];

function Panel() {
  return <div style={{ maxWidth: 680 }}><MessagesPanel onContact={() => {}} history={{ messages }} automatic={<p className="kit-muted">Welcome and payout messages are sent automatically.</p>} /></div>;
}

Loading, error and empty

status="loading" and status="error" (with error for the reason and onRetry for Try again) replace the list; an empty messages says nothing was sent yet.

Code
import { Card, MessageHistoryList, type BrandMessage } from '@ergasti/bricks';

const messages: BrandMessage[] = [
  { id: 1, name: 'Winter glow is live', body_en: 'Our Winter glow challenge starts today. Pick your gift in the app.', body_ar: 'تحدي Winter glow بدأ النهارده. اختار هديتك من التطبيق.', channel: 'whatsapp', status: 'sent', sent_at: '2026-11-12T10:00:00+02:00', sent_by: 'trndr_on_behalf', audience: { kind: 'all' }, recipients: 304, delivered: 298 },
  { id: 2, name: 'Top sellers bonus', body_en: 'You are in the top sellers group: the bonus is on.', body_ar: null, channel: 'sms', status: 'sent', sent_at: '2026-11-08T12:30:00+02:00', sent_by: 'brand', audience: { kind: 'group', groups: [{ id: 'g1', name: 'Top sellers' }] }, recipients: 4, delivered: 4 },
  { id: 3, name: 'Elite creators', body_en: 'A note for our Elite tier.', body_ar: null, channel: 'whatsapp', status: 'queued', sent_at: null, sent_by: 'trndr_on_behalf', audience: { kind: 'tier', tiers: ['elite'] }, recipients: null, delivered: null },
];

function States() {
  return (
    <div style={{ maxWidth: 620, display: 'grid', gap: 16 }}>
      <Card><MessageHistoryList messages={[]} status="loading" /></Card>
      <Card><MessageHistoryList messages={[]} status="error" error="Messages could not be loaded. Check your connection." onRetry={() => {}} /></Card>
      <Card><MessageHistoryList messages={[]} /></Card>
    </div>
  );
}

With a pager

pager sits under the list: pass the kit Pager and fetch the page on change. labels and itemLabels override single words (here the list's name and the not-sent line).

Code
import { MessageHistoryList, Pager, type BrandMessage } from '@ergasti/bricks';
import { useState } from 'react';

const messages: BrandMessage[] = [
  { id: 1, name: 'Winter glow is live', body_en: 'Our Winter glow challenge starts today. Pick your gift in the app.', body_ar: 'تحدي Winter glow بدأ النهارده. اختار هديتك من التطبيق.', channel: 'whatsapp', status: 'sent', sent_at: '2026-11-12T10:00:00+02:00', sent_by: 'trndr_on_behalf', audience: { kind: 'all' }, recipients: 304, delivered: 298 },
  { id: 2, name: 'Top sellers bonus', body_en: 'You are in the top sellers group: the bonus is on.', body_ar: null, channel: 'sms', status: 'sent', sent_at: '2026-11-08T12:30:00+02:00', sent_by: 'brand', audience: { kind: 'group', groups: [{ id: 'g1', name: 'Top sellers' }] }, recipients: 4, delivered: 4 },
  { id: 3, name: 'Elite creators', body_en: 'A note for our Elite tier.', body_ar: null, channel: 'whatsapp', status: 'queued', sent_at: null, sent_by: 'trndr_on_behalf', audience: { kind: 'tier', tiers: ['elite'] }, recipients: null, delivered: null },
];

function Paged() {
  const [page, setPage] = useState(1);
  return (
    <div style={{ maxWidth: 620 }}>
      <MessageHistoryList
        messages={messages.slice(page - 1, page + 1)}
        pager={<Pager page={page} lastPage={2} total={3} perPage={2} loading={false} label="Messages" onPage={setPage} />}
        labels={{ label: 'Messages to Glow Lab creators' }} itemLabels={{ notSent: 'Waiting to go out' }}
      />
    </div>
  );
}

contactUrl (the API's contact_url) makes "Contact TRNDR" a link; empty or null hides it. The history takes the same states as the list.

Code
import { MessagesPanel, type BrandMessage } from '@ergasti/bricks';

const messages: BrandMessage[] = [
  { id: 1, name: 'Winter glow is live', body_en: 'Our Winter glow challenge starts today. Pick your gift in the app.', body_ar: 'تحدي Winter glow بدأ النهارده. اختار هديتك من التطبيق.', channel: 'whatsapp', status: 'sent', sent_at: '2026-11-12T10:00:00+02:00', sent_by: 'trndr_on_behalf', audience: { kind: 'all' }, recipients: 304, delivered: 298 },
  { id: 2, name: 'Top sellers bonus', body_en: 'You are in the top sellers group: the bonus is on.', body_ar: null, channel: 'sms', status: 'sent', sent_at: '2026-11-08T12:30:00+02:00', sent_by: 'brand', audience: { kind: 'group', groups: [{ id: 'g1', name: 'Top sellers' }] }, recipients: 4, delivered: 4 },
  { id: 3, name: 'Elite creators', body_en: 'A note for our Elite tier.', body_ar: null, channel: 'whatsapp', status: 'queued', sent_at: null, sent_by: 'trndr_on_behalf', audience: { kind: 'tier', tiers: ['elite'] }, recipients: null, delivered: null },
];

function PanelLink() {
  return <div style={{ maxWidth: 680 }}><MessagesPanel contactUrl="https://wa.me/201000000000" history={{ messages: [], status: 'loading' }} /></div>;
}

Props

Prop

Type

Labels

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

messageHistoryItem
KeyEnglishArabic
itemLabel{name}, {date}{name}، {date}
notSentNot sent yetلسه ماتبعتتش
byTrndrSent by TRNDR on your behalfبعتها فريق TRNDR بالنيابة عنك
byBrandSent by youإنت اللي بعتها
toToلـ
audience.allAll your creatorsكل صنّاع المحتوى بتوعك
audience.ruleCreators matching a ruleصنّاع المحتوى اللي مطابقين لقاعدة
audience.groupsGroups: {names}المجموعات: {names}
audience.tiersTiers: {names}المستويات: {names}
audience.picked2 picked creatorsليس رقمًا صانع محتوى متختارين
listSeparator, ،
recipientsSent toاتبعتت لـ
deliveredDeliveredوصلت
deliveredOf{p}%{p}%
unknown——
noBodyNo text in this language.مفيش نص باللغة دي.
channels.smsSMSSMS
channels.whatsappWhatsAppواتساب
statuses.sentSentاتبعتت
statuses.deliveredDeliveredوصلت
statuses.sendingSendingبتتبعت
statuses.scheduledScheduledمتجدولة
statuses.failedFailedماوصلتش
statuses.draftDraftمسودة

Design guidance

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

One sent message, read-only: its name, channel and status pills, the date, who sent it, the text in the page's language, who it went to, and how many it was sent to and delivered; use it inside MessageHistoryList.

Brands do not send messages to creators; TRNDR does (the v3 brand mock's menu notes "messages to creators moved to the PR portal"). This block shows the history the API returns, field names unchanged (body_en, sent_at, sent_by). The body shows in the page language, or the other language (marked with its own lang and direction) when that one is empty.

Anatomy

  1. Article: article.kit-blk-msg, named "Spring launch, 3 Nov 2026" (or "Not sent yet").
  2. Head: name h3; channel Pill (mute: "SMS", "WhatsApp"); status Pill by tone; date (visual only).
  3. Sender: "Sent by TRNDR on your behalf" (trndr style) or "Sent by you".
  4. Body: the text with lang / dir, or muted "No text in this language."
  5. Facts: dl: To (audience words), Sent to, Delivered (+ "· 94%").

Variants

statusPill toneText
sent, deliveredok"Sent", "Delivered"
sending, scheduledwarn"Sending", "Scheduled"
failedbad"Failed"
draft / othermute"Draft" / the key itself
audience.kindTo
all"All your creators"
rule"Creators matching a rule"
group"Groups: Top sellers, New this month"
tier"Tiers: Elite, Rising" (tier names from the provider)
picked"12 picked creators"

States

StateTrigger
Not sentsent_at: null: "Not sent yet".
Unknown countsrecipients / delivered null: "—", no percent.
Other-language bodypage-language body empty: the other one, in its direction.
No bodyboth empty: "No text in this language."

Types

Helper: messageBody(message, lang).

BrandMessage (message): { id, name, body_en, body_ar, channel, status, sent_at, sent_by: 'trndr_on_behalf' | 'brand', audience: { kind, groups?, tiers? }, recipients, delivered }.

Usage

<MessageHistoryItem message={{
  id: 31, name: 'Spring launch', channel: 'whatsapp', status: 'delivered', sent_at: '2026-11-03T10:00:00Z',
  sent_by: 'trndr_on_behalf', audience: { kind: 'group', groups: [{ id: 'g1', name: 'Top sellers' }] },
  body_en: 'New spring collection is live. Share your coupon this week for double commission.', body_ar: null,
  recipients: 120, delivered: 113,
}} />

Where it appears

Guidelines

Do

  • Pass API rows unchanged.

Don't

  • Don't add send or edit actions; the brand's view is read-only.

RTL and Arabic

  • Body direction follows its language, not the page. Counts LTR. Arabic: "بعتها فريق TRNDR بالنيابة عنك", "وصلت", "واتساب".

Tokens

--soft, --ink-2, --ink-3, --lilac-ink (the TRNDR sender line), --lh-ar; pill tones (ok / warn / bad / mute).

Accessibility

  • An article named by the message and date; the visual date is aria-hidden (already in the name).
  • Body carries lang, so screen readers switch voice.

Found in the source

  • ARIA attributes set: aria-label, aria-hidden.

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

See also: Pill · useBricks · useLanguage · Card · Pager

Source

src/blocks/messages/MessageHistoryItem.tsx (line 131) on GitHub.

On this page