Credit Log
CreditLog renders the signed-in company’s recent credit activity, newest first: what drew credits and who, plus grants, top-ups and expiries. A few rows show at first, and “See full log” opens a table that pages back through the rest. The card loads from the company billing API, so it needs a session on the provider as described in the Drop-in components overview.
Usage
Props
Rows
Each row names what happened and when, with the amount beside it. Amounts are bare numbers with their sign, such as “−20” for a draw and “+500” for a grant, shown to up to ten fraction digits. A log in one credit names the credit once, beside the heading. A log across several credits, or one with showHeader off, names each row’s credit instead.
A draw reads as the feature it was for, or “Usage” when it names none. A refunded draw reads “Refund: Image generation”, and a manual correction to usage reads “Usage adjustment”. A grant reads as where it came from: “Plan grant”, “Free credits”, “Credit adjustment”, “Rolled over”, “Purchased Booster” for a bundle, or “Auto top-up, Booster”. An expiry says why the credits left: “Unused grant expired”, “Unused credits reset”, “Removed on plan change”, “Removed with license”, or “Credits removed”.
Under each row, the time reads “Today, 3:40 PM”, “Yesterday, 3:40 PM”, or “Oct 26, 3:40 PM” in the viewer’s time zone. Beside it is who the row is attributed to: the user behind a draw, or for a grant and its expiry where the credits came from, “Plan”, “Purchase”, “Auto top-up”, or “Manual”. A draw sent without a user names no one. The server already folds the ledger, so a draw written against several grants is one row, and each user’s share of a draw is its own.
The full log
“See full log” shows when there are more rows than limit, or more on the server. It opens a table in place with Date, Activity, By, and Amount columns, and a Credit column before Amount when the rows name their credit. “Load more” fetches the next page until the server has nothing older, and disables while a page is on the wire. “See less” collapses back to limit rows.
Long names in the By and Credit columns stop at two lines with an ellipsis, and show in full on hover. A table too wide for the card scrolls sideways, and takes keyboard focus so it can. In a card narrower than 30rem, the table stacks each row: the activity and the amount, then the date, who, and credit beneath.
Pass onSeeAll or seeAllUrl to send the customer to a page of your own instead. The button then reads “See all”, and the table never opens in place.
An empty log reads “No credit activity yet”.
Errors
A failure with nothing to show replaces the content with a short message and a “Try again” button. A 404 reads “Credit activity is not available for this account.”, because that status means the account is not enabled for the company billing endpoints. Every other failure, and a 404 under rows already loaded, reads “There was a problem retrieving your credit activity.” A page or refetch that fails with rows on screen is reported under them rather than replacing them. In development the component logs the underlying error to the console beside the copy.
Strings
Every word the card renders resolves through strings on the component, then on the provider, then the provider’s translate, then English. See Localization for how the chain works. These are the component’s own keys:
The Unnamed forms stand in when the refund names no feature or the top-up no bundle.
Markup
This is what the component renders, for a host styling it without SchematicStyles. Styling and theming lists the shared classes.
The full log replaces the list and its actions:
With showHeader off, the list, the scroll region, and the table carry aria-label="Credit activity" in place of aria-labelledby.
While loading, the root carries data-state="pending" and aria-busy="true", with a visually hidden schematic-hidden loading label and a schematic-skeleton: a heading bar when showHeader is set, then limit rows up to three, each with an action and an amount cell. On a failure with nothing to show, the root carries data-state="error" and holds a schematic-status row.
Build it yourself
useCreditLedger returns the company’s credit activity a page at a time, with loadMore for the next. deriveCreditLog turns a page into rows keyed for copy, with the amounts and times formatted beside the raw values.