refactor: align tariff builder with bot functionality

- Remove unused fields: custom_days, custom_traffic (bot doesn't use them)
- Add promo groups selection to tariff form
- Add API endpoint for fetching available promo groups
- Make traffic topup packages dynamic (add/remove any number)
- Fix stuck 0 in number inputs when clearing
- Add validation messages explaining why save button is blocked
- Match bot validation: name 2-50 chars, device_limit >= 1, tier_level 1-10
- Add missing i18n translations for new fields and validation errors
This commit is contained in:
c0mrade
2026-02-02 04:27:52 +03:00
parent 8cd95b84fb
commit d6edb659a3
6 changed files with 430 additions and 297 deletions

View File

@@ -1251,6 +1251,7 @@
"nameLabel": "Tariff name",
"nameExamplePeriod": "E.g.: Standard",
"nameExampleDaily": "E.g.: Daily",
"nameHint": "2 to 50 characters",
"descriptionLabel": "Description",
"descriptionPlaceholder2": "Brief tariff description",
"trafficLimitLabel": "Traffic limit",
@@ -1267,8 +1268,12 @@
"addButton": "Add",
"noPeriodsHint": "No added periods. Add at least one period.",
"daysShort": "d.",
"serversTitle": "Servers",
"serversTabHint": "Select servers available on this tariff.",
"noServersAvailable": "No servers available",
"promoGroupsTitle": "Promo Groups",
"promoGroupsHint": "Select promo groups that have access to this tariff. If none selected — available to everyone.",
"noPromoGroups": "No promo groups",
"extraDeviceTitle": "Additional devices",
"devicePriceLabel": "Device price (30 days):",
"devicePriceHint": "0 = device purchase unavailable",
@@ -1278,6 +1283,8 @@
"trafficMaxLimitLabel": "Max. limit:",
"trafficLimitHint2": "(0 = no limits)",
"trafficPackagesLabel": "Traffic packages:",
"addPackageTitle": "Add package",
"noPackagesHint": "No packages added. Add at least one package.",
"gbPackageUnit": "GB:",
"customDaysTitle": "Custom number of days",
"customDaysDesc": "User selects subscription duration",
@@ -1309,7 +1316,18 @@
"dailyPriceLabel": "Price per day",
"currencyPerDay": "\u20bd/day",
"dailyDeductionDesc": "Charged daily from user's balance",
"dailyPriceRequired": "Enter a price per day greater than 0"
"dailyPriceRequired": "Enter a price per day greater than 0",
"cannotSave": "Cannot save tariff:",
"validation": {
"nameRequired": "Enter tariff name",
"nameLength": "Name must be 2 to 50 characters",
"deviceLimitRequired": "Specify number of devices (minimum 1)",
"tierLevelInvalid": "Tier level must be between 1 and 10",
"fieldsRequired": "Fill in required fields (devices, tier level)",
"periodsRequired": "Add at least one period",
"dailyPriceRequired": "Enter a price per day greater than 0",
"trafficPackagesRequired": "Add at least one traffic package (or disable traffic topup)"
}
},
"servers": {
"title": "Server Management",