mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 10:16:49 +00:00
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:
@@ -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();
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user