fix(web): конвертировать тарифы VPS в базовую валюту настроек
Docker / build (push) Failing after 21s
Docker / build (push) Failing after 21s
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -305,6 +305,11 @@ export function formatInProviderCurrency(
|
||||
appSettings: Settings[] | Settings | null,
|
||||
ratesData: RatesData | null,
|
||||
): string {
|
||||
const settings: Partial<Settings> = Array.isArray(appSettings)
|
||||
? (appSettings[0] ?? {})
|
||||
: (appSettings ?? {})
|
||||
const autoConvert = settings.autoConvert !== false
|
||||
if (!autoConvert) return formatCurrency(amount, currency)
|
||||
const converted = convertWithProviderRate(amount, currency, provider, appSettings, ratesData)
|
||||
return formatCurrency(converted.value, converted.currency)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
StickyNoteIcon,
|
||||
} from 'lucide-react'
|
||||
|
||||
import { snapshotQueryOptions } from '@/queries/snapshot'
|
||||
import { snapshotQueryOptions, ratesQueryOptions } from '@/queries/snapshot'
|
||||
import { PageShell } from '@/components/page-shell'
|
||||
import { PageHeader } from '@/components/page-header'
|
||||
import { QueryState } from '@/components/query-state'
|
||||
@@ -24,6 +24,8 @@ import { getPaidUntilDate } from '@/lib/paid-until'
|
||||
import {
|
||||
effectiveVpsTariffCurrency,
|
||||
formatCurrency,
|
||||
formatInProviderCurrency,
|
||||
normalizeRatesPayload,
|
||||
tariffTypeLabel,
|
||||
vpsStatusLabel,
|
||||
paymentTypeLabel,
|
||||
@@ -56,6 +58,9 @@ function InfoRow({ label, value }: { label: string; value: React.ReactNode }) {
|
||||
function VpsDetailPage() {
|
||||
const { vpsId } = Route.useParams()
|
||||
const { data: snapshot, isLoading, isError, error, refetch } = useQuery(snapshotQueryOptions())
|
||||
const settings = snapshot?.settings[0]
|
||||
const { data: rawRates } = useQuery(ratesQueryOptions(settings?.ratesUrl))
|
||||
const ratesData = normalizeRatesPayload(rawRates) ?? rawRates ?? null
|
||||
|
||||
const vps = snapshot?.vps.find((v) => v.id === vpsId)
|
||||
const providerById = snapshot ? providerByIdMap(snapshot.providers) : new Map()
|
||||
@@ -215,9 +220,12 @@ function VpsDetailPage() {
|
||||
<InfoRow label="Тип" value={tariffTypeLabel(row.tariffType)} />
|
||||
<InfoRow
|
||||
label="Ставка"
|
||||
value={formatCurrency(
|
||||
value={formatInProviderCurrency(
|
||||
vpsTariffRateAmount(row),
|
||||
effectiveVpsTariffCurrency(row, provider),
|
||||
provider,
|
||||
snapshot?.settings ?? null,
|
||||
ratesData,
|
||||
)}
|
||||
/>
|
||||
<InfoRow
|
||||
|
||||
@@ -6,7 +6,7 @@ import { toast } from 'sonner'
|
||||
import { snapshotQueryOptions, ratesQueryOptions } from '@/queries/snapshot'
|
||||
import { api, ApiError } from '@/lib/api-client'
|
||||
import type { VpsFormValues } from '@/lib/schemas'
|
||||
import { normalizeRatesPayload, effectiveVpsTariffCurrency, formatCurrency, vpsStatusLabel, tariffTypeLabel, vpsTariffRateAmount, vpsTariffMonthlyBurn } from '@/lib/format'
|
||||
import { normalizeRatesPayload, effectiveVpsTariffCurrency, formatInProviderCurrency, vpsStatusLabel, tariffTypeLabel, vpsTariffRateAmount, vpsTariffMonthlyBurn } from '@/lib/format'
|
||||
import { PageShell } from '@/components/page-shell'
|
||||
import { PageHeader } from '@/components/page-header'
|
||||
import { Button } from '@cfdm/ui/components/button'
|
||||
@@ -413,7 +413,10 @@ function VpsPage() {
|
||||
const provider = providerById.get(v.providerId)
|
||||
const currency = effectiveVpsTariffCurrency(v, provider)
|
||||
const amount = vpsTariffRateAmount(v)
|
||||
return dataGridCellStack(formatCurrency(amount, currency), tariffTypeLabel(v.tariffType))
|
||||
return dataGridCellStack(
|
||||
formatInProviderCurrency(amount, currency, provider, snapshot?.settings ?? null, ratesData),
|
||||
tariffTypeLabel(v.tariffType),
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user