import { useUsageEvents } from "priceos/react";
import type { MyFeatures } from "./priceos.types";
export function CreditsUsageHistory() {
const { usageEvents, hasMore, getMore, isLoading } = useUsageEvents<MyFeatures>("credits", {
period: "current",
limit: 20,
});
if (isLoading) return <div>Loading...</div>;
return (
<div>
<ul>
{usageEvents.map((event) => (
<li key={event.id}>
{event.amount} at {new Date(event.occurredAt).toLocaleString()}
</li>
))}
</ul>
{hasMore ? <button onClick={() => void getMore()}>Load more</button> : null}
</div>
);
}