feat(admin): require expiration for credit grants unless 'Never expire' is checked#44
feat(admin): require expiration for credit grants unless 'Never expire' is checked#44kiloconnect[bot] wants to merge 3 commits intomainfrom
Conversation
…e' is checked - Add 'Never expire' checkbox to the credit grant form - Make expiration date OR expiry hours required by default - Only allow empty expiration fields if 'Never expire' is checked - Show validation warning when expiration is missing - Disable expiration fields when 'Never expire' is checked - Clear expiration fields when 'Never expire' is toggled on
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)CRITICAL
WARNING
Files Reviewed (1 files) |
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
|
Tested and works |
| selectedCreditCategory?.expiry_hours != null || | ||
| selectedCreditCategory?.credit_expiry_date != null; | ||
| const hasExpirationFromForm = expirationDate.trim() !== '' || Number(expiryHours) > 0; | ||
| const hasExpiration = hasExpirationFromCategory || hasExpirationFromForm || neverExpire; |
There was a problem hiding this comment.
WARNING: "Never expire" doesn’t override category defaults
src/app/admin/components/UserAdmin/UserAdminCreditGrant.tsx:64 treats neverExpire as satisfying the "must have an expiration" validation, but the request payload sent in UserAdminCreditGrant.handleGrantCredit() doesn’t include any flag/override to tell the server to ignore selectedCreditCategory defaults. If the selected category has expiry_hours/credit_expiry_date, checking "Never expire" will still grant expiring credits (contradicting the UI text).
Consider either (a) sending an explicit override (e.g. never_expire: true or expiry_hours: null / credit_expiry_date: null with server support), or (b) hiding/disabled the checkbox when the category already has an expiry.
Summary
This PR updates the admin user credit grant form to require an expiration date or expiration hours for credit grants, unless the admin explicitly checks a "Never expire" checkbox.
Changes
How it works
expiry_hoursorcredit_expiry_date)Testing
pnpm typecheckBuilt for Brendan by Kilo for Slack