mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-12 18:15:48 +00:00
refactor(ui): update cliproxy page for account control flow
This commit is contained in:
1 parent
87226e05c4
commit
118ce46e72
1 file changed
+35
@@ -24,6 +24,9 @@ import {
|
|||||||
useRemoveAccount,
|
useRemoveAccount,
|
||||||
usePauseAccount,
|
usePauseAccount,
|
||||||
useResumeAccount,
|
useResumeAccount,
|
||||||
|
useSoloAccount,
|
||||||
|
useBulkPauseAccounts,
|
||||||
|
useBulkResumeAccounts,
|
||||||
useDeleteVariant,
|
useDeleteVariant,
|
||||||
} from '@/hooks/use-cliproxy';
|
} from '@/hooks/use-cliproxy';
|
||||||
import type { AuthStatus, Variant } from '@/lib/api-client';
|
import type { AuthStatus, Variant } from '@/lib/api-client';
|
||||||
@@ -185,6 +188,9 @@ export function CliproxyPage() {
|
|||||||
const removeMutation = useRemoveAccount();
|
const removeMutation = useRemoveAccount();
|
||||||
const pauseMutation = usePauseAccount();
|
const pauseMutation = usePauseAccount();
|
||||||
const resumeMutation = useResumeAccount();
|
const resumeMutation = useResumeAccount();
|
||||||
|
const soloMutation = useSoloAccount();
|
||||||
|
const bulkPauseMutation = useBulkPauseAccounts();
|
||||||
|
const bulkResumeMutation = useBulkResumeAccounts();
|
||||||
const deleteMutation = useDeleteVariant();
|
const deleteMutation = useDeleteVariant();
|
||||||
|
|
||||||
// Selection state: either a provider or a variant
|
// Selection state: either a provider or a variant
|
||||||
@@ -232,6 +238,21 @@ export function CliproxyPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSoloMode = (provider: string, accountId: string) => {
|
||||||
|
if (soloMutation.isPending) return;
|
||||||
|
soloMutation.mutate({ provider, accountId });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBulkPause = (provider: string, accountIds: string[]) => {
|
||||||
|
if (bulkPauseMutation.isPending) return;
|
||||||
|
bulkPauseMutation.mutate({ provider, accountIds });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBulkResume = (provider: string, accountIds: string[]) => {
|
||||||
|
if (bulkResumeMutation.isPending) return;
|
||||||
|
bulkResumeMutation.mutate({ provider, accountIds });
|
||||||
|
};
|
||||||
|
|
||||||
const handleSelectProvider = (provider: string) => {
|
const handleSelectProvider = (provider: string) => {
|
||||||
setSelectedProvider(provider);
|
setSelectedProvider(provider);
|
||||||
setSelectedVariant(null);
|
setSelectedVariant(null);
|
||||||
@@ -380,8 +401,16 @@ export function CliproxyPage() {
|
|||||||
onPauseToggle={(accountId, paused) =>
|
onPauseToggle={(accountId, paused) =>
|
||||||
handlePauseToggle(selectedVariantData.provider, accountId, paused)
|
handlePauseToggle(selectedVariantData.provider, accountId, paused)
|
||||||
}
|
}
|
||||||
|
onSoloMode={(accountId) => handleSoloMode(selectedVariantData.provider, accountId)}
|
||||||
|
onBulkPause={(accountIds) => handleBulkPause(selectedVariantData.provider, accountIds)}
|
||||||
|
onBulkResume={(accountIds) =>
|
||||||
|
handleBulkResume(selectedVariantData.provider, accountIds)
|
||||||
|
}
|
||||||
isRemovingAccount={removeMutation.isPending}
|
isRemovingAccount={removeMutation.isPending}
|
||||||
isPausingAccount={pauseMutation.isPending || resumeMutation.isPending}
|
isPausingAccount={pauseMutation.isPending || resumeMutation.isPending}
|
||||||
|
isSoloingAccount={soloMutation.isPending}
|
||||||
|
isBulkPausing={bulkPauseMutation.isPending}
|
||||||
|
isBulkResuming={bulkResumeMutation.isPending}
|
||||||
/>
|
/>
|
||||||
) : selectedStatus ? (
|
) : selectedStatus ? (
|
||||||
<ProviderEditor
|
<ProviderEditor
|
||||||
@@ -412,8 +441,14 @@ export function CliproxyPage() {
|
|||||||
onPauseToggle={(accountId, paused) =>
|
onPauseToggle={(accountId, paused) =>
|
||||||
handlePauseToggle(selectedStatus.provider, accountId, paused)
|
handlePauseToggle(selectedStatus.provider, accountId, paused)
|
||||||
}
|
}
|
||||||
|
onSoloMode={(accountId) => handleSoloMode(selectedStatus.provider, accountId)}
|
||||||
|
onBulkPause={(accountIds) => handleBulkPause(selectedStatus.provider, accountIds)}
|
||||||
|
onBulkResume={(accountIds) => handleBulkResume(selectedStatus.provider, accountIds)}
|
||||||
isRemovingAccount={removeMutation.isPending}
|
isRemovingAccount={removeMutation.isPending}
|
||||||
isPausingAccount={pauseMutation.isPending || resumeMutation.isPending}
|
isPausingAccount={pauseMutation.isPending || resumeMutation.isPending}
|
||||||
|
isSoloingAccount={soloMutation.isPending}
|
||||||
|
isBulkPausing={bulkPauseMutation.isPending}
|
||||||
|
isBulkResuming={bulkResumeMutation.isPending}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<EmptyProviderState onSetup={() => setWizardOpen(true)} />
|
<EmptyProviderState onSetup={() => setWizardOpen(true)} />
|
||||||
|
|||||||
Reference in new issue
Block a user