-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: enable card correctly #2794
Conversation
the card was disabled when the remaining reached 0, which is a perfectly fine state, as long as the refill is configured to be greater than 0 as well
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
📝 WalkthroughWalkthroughThe pull request modifies the Changes
Sequence DiagramsequenceDiagram
participant User
participant UpdateKeyRemaining
participant APIKey
User->>UpdateKeyRemaining: Open key settings
UpdateKeyRemaining->>APIKey: Retrieve key details
UpdateKeyRemaining->>UpdateKeyRemaining: Determine limitEnabled
alt Limit Enabled
UpdateKeyRemaining-->>User: Show limit configuration options
else Limit Disabled
UpdateKeyRemaining-->>User: Hide limit configuration
end
The sequence diagram illustrates how the updated Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/update-key-remaining.tsx (1)
Line range hint
70-77
: Consider adding validation for consistent form state.The form initialization allows for a potentially inconsistent state where
limitEnabled
is true butremaining
is undefined. Consider adding validation in the form schema to ensure that whenlimitEnabled
is true,remaining
must be defined.const formSchema = z.object({ keyId: z.string(), limitEnabled: z.boolean(), - remaining: z.coerce.number().positive({ message: "Please enter a positive number" }).optional(), + remaining: z.coerce + .number() + .positive({ message: "Please enter a positive number" }) + .optional() + .superRefine((val, ctx) => { + const limitEnabled = ctx.parent.limitEnabled; + if (limitEnabled && val === undefined) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: "Remaining uses must be set when limit is enabled", + }); + } + }), refill: z .object({
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/update-key-remaining.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (17)
- GitHub Check: Test Packages / Test ./packages/rbac
- GitHub Check: Test Packages / Test ./packages/nextjs
- GitHub Check: Test Packages / Test ./packages/hono
- GitHub Check: Test Packages / Test ./packages/cache
- GitHub Check: Test Packages / Test ./packages/api
- GitHub Check: Test Packages / Test ./internal/clickhouse
- GitHub Check: Test Packages / Test ./internal/resend
- GitHub Check: Test Packages / Test ./internal/keys
- GitHub Check: Test Packages / Test ./internal/id
- GitHub Check: Test Packages / Test ./internal/hash
- GitHub Check: Test Packages / Test ./internal/encryption
- GitHub Check: Test Packages / Test ./internal/billing
- GitHub Check: Test API / API Test Local
- GitHub Check: Test Agent Local / test_agent_local
- GitHub Check: Build / Build
- GitHub Check: autofix
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/settings/update-key-remaining.tsx (1)
70-70
: LGTM! The change correctly fixes the card enabling logic.The updated condition
Boolean(apiKey.remaining) || Boolean(apiKey.refillAmount)
properly enables the card when either remaining uses or refill amount is configured, fixing the issue where the card was disabled when remaining balance reached zero but refill was configured.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Tested and works now.
the card was disabled when the remaining reached 0,
which is a perfectly fine state, as long as the refill
is configured to be greater than 0 as well
Summary by CodeRabbit