Refactor client update handling to support nullable parameters for name and expiration
- Updated the `UpdateClientAsync` method in `IXuiPanelGateway` to accept nullable parameters for `name` and `expiresAt`, allowing for more flexible client management without unintended modifications. - Adjusted the `BlockUserCommandHandler`, `UnblockUserCommandHandler`, and other related command handlers to utilize the new nullable parameters, ensuring that client names remain unchanged during block/unblock operations and that expiration dates are managed correctly. - Enhanced the billing and configuration handling to reflect the new logic for managing client states based on expiration rather than enabling/disabling, improving reliability in client status management. - Updated tests to cover the new behavior and ensure proper functionality across the application.
This commit is contained in:
@@ -30,6 +30,12 @@ function ConfigsList() {
|
||||
const inboundsQuery = useQuery({ queryKey: ['available-inbounds'], queryFn: listAvailableInbounds })
|
||||
const billingStatusQuery = useQuery({ queryKey: ['my-billing-status'], queryFn: getMyBillingStatus })
|
||||
|
||||
// Зеркалит серверную проверку в CreateVpnConfigCommandHandler (ConfigErrors.BillingRequired) —
|
||||
// роль с биллингом и просроченной/неоплаченной подпиской не может создавать новые конфиги.
|
||||
const billing = billingStatusQuery.data
|
||||
const billingBlocksCreate =
|
||||
!!billing?.billingEnabled && (billing.paidUntil == null || new Date(billing.paidUntil) < new Date())
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-10">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
@@ -52,7 +58,14 @@ function ConfigsList() {
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
{inboundsQuery.data?.length === 0 ? (
|
||||
{billingBlocksCreate ? (
|
||||
<div className="flex max-w-xs flex-col items-end gap-1 text-right text-sm">
|
||||
<p className="text-muted-foreground">{t('configs.billingRequiredNotice')}</p>
|
||||
<Link to="/billing" className="font-medium text-foreground underline underline-offset-2">
|
||||
{t('configs.goToBilling')}
|
||||
</Link>
|
||||
</div>
|
||||
) : inboundsQuery.data?.length === 0 ? (
|
||||
<p className="max-w-xs text-right text-sm text-muted-foreground">{t('configs.noInboundsNotice')}</p>
|
||||
) : (
|
||||
inboundsQuery.data && <CreateConfigDialog inbounds={inboundsQuery.data} />
|
||||
|
||||
Reference in New Issue
Block a user