From 7ef42ee7e87d1c07bb58983a9d7e5f69c767c590 Mon Sep 17 00:00:00 2001 From: Denozordec Date: Fri, 26 Jun 2026 22:33:44 +0700 Subject: [PATCH] =?UTF-8?q?fix(web):=20VPS=20=E2=80=94=20=D0=BA=D0=BE?= =?UTF-8?q?=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=B0=D1=8F=20=D0=B2=D0=B0?= =?UTF-8?q?=D0=BB=D1=8E=D1=82=D0=B0=20=D1=82=D0=B0=D1=80=D0=B8=D1=84=D0=B0?= =?UTF-8?q?=20=D0=B8=20=D0=BA=D0=BE=D0=BD=D0=B2=D0=B5=D1=80=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=BA=D1=83=D1=80=D1=81=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B2=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Раньше в колонке тарифа вызывался formatInBaseCurrency с ratesData=null, поэтому 0.8 EUR отображались как «0,80 ₽» (без конвертации, но в базовой валюте). Теперь: - ratesData грузится через ratesQueryOptions (как на dashboard/reports); - валюта тарифа определяется через effectiveVpsTariffCurrency (приоритет baseCurrency провайдера, затем vps.currency); - форматирование через formatInProviderCurrency — учитывает курсы провайдера (usdRate/eurRate) и глобальные курсы, при их отсутствии показывает сумму в исходной валюте, а не в базовой. Co-authored-by: Cursor --- apps/web/src/routes/_auth/vps.tsx | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/web/src/routes/_auth/vps.tsx b/apps/web/src/routes/_auth/vps.tsx index c8a1e0f..d28c5e7 100644 --- a/apps/web/src/routes/_auth/vps.tsx +++ b/apps/web/src/routes/_auth/vps.tsx @@ -4,9 +4,10 @@ import { useState, useMemo } from 'react' import { PlusIcon, PencilIcon, Trash2Icon } from 'lucide-react' import { toast } from 'sonner' -import { snapshotQueryOptions } from '@/queries/snapshot' +import { snapshotQueryOptions, ratesQueryOptions } from '@/queries/snapshot' import { api, ApiError } from '@/lib/api-client' import { vpsSchema, type VpsFormValues } from '@/lib/schemas' +import { normalizeRatesPayload, effectiveVpsTariffCurrency, formatInProviderCurrency } from '@/lib/format' import { PageShell } from '@/components/page-shell' import { PageHeader } from '@/components/page-header' import { Button } from '@cfdm/ui/components/button' @@ -30,7 +31,7 @@ import { } from '@/components/vps-filters' import type { Vps } from '@/types/entities' -import { vpsStatusLabel, tariffTypeLabel, formatInBaseCurrency } from '@/lib/format' +import { vpsStatusLabel, tariffTypeLabel } from '@/lib/format' import { providerByIdMap, accountSelectLabel } from '@/lib/billmanager' export const Route = createFileRoute('/_auth/vps')({ @@ -54,6 +55,10 @@ function VpsPage() { const [filters, setFilters] = useState(buildDefaultVpsFilters()) const [presets, setPresets] = useState(() => loadFilterPresets()) + const settings = snapshot?.settings[0] + const { data: rawRates } = useQuery(ratesQueryOptions(settings?.ratesUrl)) + const ratesData = normalizeRatesPayload(rawRates) ?? rawRates ?? null + const createMutation = useMutation({ mutationFn: (record: VpsFormValues) => api.create('vps', record as unknown as Vps), onSuccess: () => { @@ -195,17 +200,17 @@ function VpsPage() { { key: 'tariff', header: 'Тариф', - cell: (v) => ( - - {formatInBaseCurrency( - v.tariffType === 'daily' ? Number(v.dailyRate || 0) * 30 : Number(v.monthlyRate || 0), - v.currency, - snapshot?.settings ?? [], - null, - )} - {tariffTypeLabel(v.tariffType)} - - ), + cell: (v) => { + const provider = providerById.get(v.providerId) + const currency = effectiveVpsTariffCurrency(v, provider) + const amount = v.tariffType === 'daily' ? Number(v.dailyRate || 0) * 30 : Number(v.monthlyRate || 0) + return ( + + {formatInProviderCurrency(amount, currency, provider, snapshot?.settings ?? [], ratesData)} + {tariffTypeLabel(v.tariffType)} + + ) + }, }, { key: 'actions',