feat(ui): add pause/resume API hooks

- add api.cliproxy.accounts.pause/resume methods

- add usePauseAccount, useResumeAccount hooks

Refs #282
This commit is contained in:
kaitranntt
2026-01-06 12:18:02 -05:00
parent c13003d940
commit b92a35d09b
2 changed files with 51 additions and 0 deletions
+34
View File
@@ -118,6 +118,40 @@ export function useRemoveAccount() {
});
}
export function usePauseAccount() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ provider, accountId }: { provider: string; accountId: string }) =>
api.cliproxy.accounts.pause(provider, accountId),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['cliproxy-accounts'] });
queryClient.invalidateQueries({ queryKey: ['cliproxy-auth'] });
toast.success('Account paused');
},
onError: (error: Error) => {
toast.error(error.message);
},
});
}
export function useResumeAccount() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ provider, accountId }: { provider: string; accountId: string }) =>
api.cliproxy.accounts.resume(provider, accountId),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['cliproxy-accounts'] });
queryClient.invalidateQueries({ queryKey: ['cliproxy-auth'] });
toast.success('Account resumed');
},
onError: (error: Error) => {
toast.error(error.message);
},
});
}
// OAuth flow hook
export function useStartAuth() {
const queryClient = useQueryClient();
+17
View File
@@ -71,11 +71,18 @@ export interface UpdateVariant {
export interface OAuthAccount {
id: string;
email?: string;
nickname?: string;
provider: 'gemini' | 'codex' | 'agy' | 'qwen' | 'iflow' | 'kiro' | 'ghcp';
isDefault: boolean;
tokenFile: string;
createdAt: string;
lastUsedAt?: string;
/** Whether account is paused (skipped in quota rotation) */
paused?: boolean;
/** ISO timestamp when account was paused */
pausedAt?: string;
/** Account tier: free, pro, ultra */
tier?: 'free' | 'pro' | 'ultra' | 'unknown';
}
export interface AuthStatus {
@@ -392,6 +399,16 @@ export const api = {
}),
remove: (provider: string, accountId: string) =>
request(`/cliproxy/auth/accounts/${provider}/${accountId}`, { method: 'DELETE' }),
pause: (provider: string, accountId: string) =>
request<{ provider: string; accountId: string; paused: boolean }>(
`/cliproxy/auth/accounts/${provider}/${accountId}/pause`,
{ method: 'POST' }
),
resume: (provider: string, accountId: string) =>
request<{ provider: string; accountId: string; paused: boolean }>(
`/cliproxy/auth/accounts/${provider}/${accountId}/resume`,
{ method: 'POST' }
),
},
// OAuth flow
auth: {