diff --git a/frontend/src/admin/sections/TariffsSection.svelte b/frontend/src/admin/sections/TariffsSection.svelte index fc0b38b..95fda92 100644 --- a/frontend/src/admin/sections/TariffsSection.svelte +++ b/frontend/src/admin/sections/TariffsSection.svelte @@ -31,6 +31,10 @@ "TRIAL_TRAFFIC_STRATEGY", "TRIAL_SQUAD_UUIDS", ]; + const TRIAL_SWITCH_KEYS = ["TRIAL_ENABLED"]; + const TRIAL_GENERAL_KEYS = ["TRIAL_DURATION_DAYS", "TRIAL_TRAFFIC_LIMIT_GB"]; + const TRIAL_RESET_KEYS = ["TRIAL_TRAFFIC_STRATEGY"]; + const TRIAL_SQUAD_KEYS = ["TRIAL_SQUAD_UUIDS"]; const LEGACY_PERIODS = [ ["1", "MONTH_1_ENABLED", "RUB_PRICE_1_MONTH", "STARS_PRICE_1_MONTH"], ["3", "MONTH_3_ENABLED", "RUB_PRICE_3_MONTHS", "STARS_PRICE_3_MONTHS"], @@ -76,6 +80,7 @@ })); let selectedTrialSquad = ""; + let trialSquadSelectKey = 0; let tariffSettingsOpen = []; function tariffName(tariff) { @@ -122,6 +127,18 @@ settingsStore.markDirty(key, value); } + function isSettingDirty(key) { + return Boolean(settingsDirty[key]); + } + + function dirtyCount(keys) { + return (keys || []).filter((key) => isSettingDirty(key)).length; + } + + function resetSetting(key) { + settingsStore.clearDirty(key); + } + function csvList(key) { return String(valueForKey(key) || "") .split(",") @@ -139,10 +156,19 @@ function addTrialSquad(uuid) { const next = String(uuid || "").trim(); if (!next) return; - setCsvList("TRIAL_SQUAD_UUIDS", [...csvList("TRIAL_SQUAD_UUIDS"), next]); + const current = csvList("TRIAL_SQUAD_UUIDS"); + if (!current.includes(next)) { + setCsvList("TRIAL_SQUAD_UUIDS", [...current, next]); + } selectedTrialSquad = ""; } + function handleTrialSquadSelect(uuid) { + addTrialSquad(uuid); + selectedTrialSquad = ""; + trialSquadSelectKey += 1; + } + function removeTrialSquad(uuid) { setCsvList( "TRIAL_SQUAD_UUIDS", @@ -225,96 +251,323 @@ {/if} -
-
-
-