From f1413de5984859e20a58e3212270ccd1495a6954 Mon Sep 17 00:00:00 2001 From: kewldan <40865857+kewldan@users.noreply.github.com> Date: Thu, 23 Jul 2026 04:09:22 +0300 Subject: [PATCH] =?UTF-8?q?fix(tariffs):=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D1=8F=D1=82=D1=8C=20=D0=BF=D1=83=D1=81=D1=82=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=BE=D0=BC=D0=BE=D0=B3=D1=80=D1=83=D0=BF?= =?UTF-8?q?=D0=BF=D1=8B=20=D0=B8=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B8=20=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=82=D0=B0=D1=80=D0=B8=D1=84=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AdminTariffCreate.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pages/AdminTariffCreate.tsx b/src/pages/AdminTariffCreate.tsx index 8a5e095..f7203d2 100644 --- a/src/pages/AdminTariffCreate.tsx +++ b/src/pages/AdminTariffCreate.tsx @@ -4,12 +4,12 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { tariffsApi, - TariffDetail, - TariffCreateRequest, - TariffUpdateRequest, - PeriodPrice, - ServerInfo, - ExternalSquadInfo, + type TariffDetail, + type TariffCreateRequest, + type TariffUpdateRequest, + type PeriodPrice, + type ServerInfo, + type ExternalSquadInfo, } from '../api/tariffs'; import { AdminBackButton } from '../components/admin'; import { createNumberInputHandler, toNumber } from '../utils/inputHelpers'; @@ -153,9 +153,12 @@ export default function AdminTariffCreate() { const handleSubmit = () => { const isDaily = tariffType === 'daily'; + // PATCH applies a field only when it is present in the payload, so empty + // values ('' / []) must still be sent when editing — omitting them makes + // clearing the description or unchecking all promo groups impossible. const data: TariffCreateRequest | TariffUpdateRequest = { name, - description: description || undefined, + description: isEdit ? description : description || undefined, is_active: isActive, show_in_gift: showInGift, traffic_limit_gb: toNumber(trafficLimitGb, 100), @@ -167,7 +170,7 @@ export default function AdminTariffCreate() { period_prices: isDaily ? [] : periodPrices.filter((p) => p.price_kopeks >= 0), allowed_squads: selectedSquads, external_squad_uuid: selectedExternalSquad || null, - promo_group_ids: selectedPromoGroups.length > 0 ? selectedPromoGroups : undefined, + promo_group_ids: selectedPromoGroups, traffic_topup_enabled: trafficTopupEnabled, traffic_topup_packages: trafficTopupPackages, max_topup_traffic_gb: toNumber(maxTopupTrafficGb), @@ -600,7 +603,7 @@ export default function AdminTariffCreate() { setEditingPeriodPrices((prev) => ({ ...prev, [period.days]: val })); if (val !== '') { const num = parseFloat(val); - if (!isNaN(num)) { + if (!Number.isNaN(num)) { updatePeriodPrice(period.days, Math.max(0, num)); } } @@ -938,7 +941,7 @@ export default function AdminTariffCreate() { setEditingPackagePrices((prev) => ({ ...prev, [gb]: val })); if (val !== '') { const num = parseFloat(val); - if (!isNaN(num)) { + if (!Number.isNaN(num)) { setTrafficTopupPackages((prev) => ({ ...prev, [gb]: Math.max(0, num) * 100,