KitPrimitives
useMoneyDisplay
One money slot's display options, every field set, the most specific winning: own (the component's money prop) → the provider's moneyFor[slot] → its money → the slot's default (MONEY_SLOTS). Pass the result to <Money money> or formatMoney.
import { useMoneyDisplay } from '@ergasti/bricks';Examples
Resolve a slot
useMoneyDisplay(slot, own) returns every field of the slot's display, the component's own options first, then the provider's moneyFor[slot], its money and the slot's built-in default. Hand the result to <Money money> or to formatMoney for a figure of your own. The provider below sets one slot app-wide.
Code
import { BricksProvider, Money, formatMoney, useBricks, useMoneyDisplay, type MoneySlot } from '@ergasti/bricks';
function Row({ slot, own }: { slot: MoneySlot; own?: Parameters<typeof useMoneyDisplay>[1] }) {
const { language, currency } = useBricks();
const display = useMoneyDisplay(slot, own);
return (
<tr>
<td><code>{slot}</code>{own ? <> with <code>{JSON.stringify(own)}</code></> : null}</td>
<td><code>{JSON.stringify(display)}</code></td>
<td><Money value="184300.50" money={display} /></td>
<td>{formatMoney('184300.50', { language, currency: currency.label, ...display })}</td>
</tr>
);
}
function Resolved() {
return (
<BricksProvider moneyFor={{ 'walletLedger.entry': { showCurrency: true } }}>
<table style={{ borderCollapse: 'collapse' }}>
<thead><tr><th>Slot</th><th>Resolved</th><th>Money</th><th>formatMoney</th></tr></thead>
<tbody>
<Row slot="money" />
<Row slot="heroCard.big" />
<Row slot="walletLedger.entry" />
<Row slot="walletLedger.entry" own={{ showCurrency: false, decimals: 0 }} />
</tbody>
</table>
</BricksProvider>
);
}Signature
function useMoneyDisplay(slot: "money" | "moneyFigure.amount" | "moneyNote.amount" | "heroCard.big" | "heroCard.row" | "walletLedger.total" | "walletLedger.entry" | "walletLedger.balance" | "walletHealthCard.lastTopup" | "challengeCard.figures" | "challengeDetail.figures" | "challengeDetail.topCreators" | "liveChallengeCard.figures" | "findCreatorCard.sales90" | "creatorProfilePanel.sales90" | "creatorProfilePanel.averageOrder" | "myCreatorPanel.figures" | "groupCard.sales" | "groupPanel.sales" | "payoutBatchDetail.total" | "payoutBatchDetail.line" | "topUpAmountPicker.preset" | "topUpAmountPicker.total" | "bundleCard.price" | "bundlePurchaseSummary.price" | "bundlePurchaseSummary.total" | "brandDetail.figures" | "challengeSummary.figures" | "challengeColumns.figures" | "fraudCaseDetail.figures" | "fraudCaseRow.figures" | "leaderboard.figures" | "challengeRequestColumns.budget" | "prCreatorColumns.sales" | "presets.figures" | "tierLadder.figures" | "customerAffiliates.figures" | "prChallengeCard.figures" | "creatorDrawer.figures" | "creatorColumns.figures" | "challengeGiftPicker.figures" | "brandRequestCard.figures", own?: MoneyDisplay | undefined): Required<MoneyDisplay>Parameters
Prop
Type
Returns
Required<MoneyDisplay>
Related
BricksProvider · Money · Avatar · AvatarStack · Button · ButtonLink
Source
src/kit/BricksProvider.tsx (line 65) on GitHub.