Let admins expire a spend-limit override at the next credit refresh - #29623
Open
avervaet wants to merge 1 commit into
Open
Let admins expire a spend-limit override at the next credit refresh#29623avervaet wants to merge 1 commit into
avervaet wants to merge 1 commit into
Conversation
Adds nextCreditResetAt to GetUserSpendLimitResponse, resolved from the same Metronome billing-period data the members usage table already uses (Redis-cached, degrades to null on any Metronome fetch failure so a read never breaks on an outage). In EditSpendLimitModal, replaces the single "expires on" date field with a three-way choice: never / on a specific date / at next credit refresh. The last option pins the override's expiresAt to the resolved Metronome date at save time, so admins don't have to guess or compute it by hand when granting a temporary increase. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
| expiresAt = spendLimit?.nextCreditResetAt ?? null; | ||
| break; | ||
| default: | ||
| assertNeverAndIgnore(expiryMode); |
Contributor
There was a problem hiding this comment.
[GEN6] Prefer exhaustive switch + assertNever over if/else on union types
expiryMode is internal component state (not API data), so a missing case is a programming error. Use assertNever (which throws at runtime) instead of assertNeverAndIgnore (which silently swallows it).
Suggested change
| assertNeverAndIgnore(expiryMode); | |
| assertNever(expiryMode); |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nextCreditResetAttoGetUserSpendLimitResponse, resolved from the same Metronome billing-period data the members usage table already uses (getCachedSeatDataByUserId, Redis-cached) — no new Metronome plumbing needed, and it degrades tonull(not an error) on any Metronome fetch failure so a spend-limit read never breaks on a Metronome outage.EditSpendLimitModal, replaces the single "expires on" date field with a three-way choice: Never / On a specific date / At next credit refresh. The third option is only shown when a next-reset date is actually resolvable, and pins the override'sexpiresAtto that resolved date at save time.Test plan
npm run test -- lib/api/users/spend_limit.test.ts(front) —nextCreditResetAtresolves from mocked Metronome seat data and degrades tonullon failure.npm run test -- "members/[uId]/spend_limit.test.ts"(front-api) —nextCreditResetAtround-trips through GET.expiresAt.Deploy plan
🤖 Generated with Claude Code