fix(admin): persist image quota by setting remaining directly

Use PUT setImageQuota so admins can lower remaining below the stored plan
limit; grant-only bonus updates silently no-op when bonus is already zero.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-05 16:22:22 +08:00
parent eca1aa635e
commit d0183cb636
3 changed files with 51 additions and 22 deletions
+16
View File
@@ -1373,6 +1373,22 @@ export async function fetchUserImageQuota(userId: string) {
}>(`/admin-api/users/${userId}/image-quota`);
}
export async function setUserImageQuota(
userId: string,
payload: { remaining?: number; total?: number },
note = '',
) {
return portalFetch<{
ok: boolean;
unchanged?: boolean;
subscription: AdminSubscription;
quota: ImageQuotaView;
}>(`/admin-api/users/${userId}/image-quota`, {
method: 'PUT',
body: JSON.stringify({ ...payload, note }),
});
}
export async function grantUserImageQuota(userId: string, delta: number, note = '') {
return portalFetch<{
ok: boolean;