mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
fix: admin promo groups - add default toggle, fix threshold reset to 0
- Added is_default toggle to promo group create/edit form - Send 0 instead of null when clearing auto-assign threshold - Added isDefault i18n keys for ru, en, zh, fa
This commit is contained in:
@@ -2538,6 +2538,7 @@
|
||||
"rub": "rub.",
|
||||
"autoAssignHint": "0 = don't auto-assign",
|
||||
"applyToAddons": "Apply to additional services",
|
||||
"isDefault": "Default group",
|
||||
"cancel": "Cancel",
|
||||
"saving": "Saving...",
|
||||
"save": "Save"
|
||||
|
||||
@@ -2200,6 +2200,7 @@
|
||||
"rub": "روبل",
|
||||
"autoAssignHint": "0 = تخصیص خودکار نشود",
|
||||
"applyToAddons": "اعمال به خدمات اضافی",
|
||||
"isDefault": "گروه پیشفرض",
|
||||
"cancel": "انصراف",
|
||||
"saving": "در حال ذخیره...",
|
||||
"save": "ذخیره"
|
||||
|
||||
@@ -3059,6 +3059,7 @@
|
||||
"rub": "руб.",
|
||||
"autoAssignHint": "0 = не назначать автоматически",
|
||||
"applyToAddons": "Применять к дополнительным услугам",
|
||||
"isDefault": "Группа по умолчанию",
|
||||
"cancel": "Отмена",
|
||||
"saving": "Сохранение...",
|
||||
"save": "Сохранить"
|
||||
|
||||
@@ -2199,6 +2199,7 @@
|
||||
"rub": "卢布",
|
||||
"autoAssignHint": "0 = 不自动分配",
|
||||
"applyToAddons": "应用于附加服务",
|
||||
"isDefault": "默认组",
|
||||
"cancel": "取消",
|
||||
"saving": "保存中...",
|
||||
"save": "保存"
|
||||
|
||||
@@ -61,6 +61,7 @@ export default function AdminPromoGroupCreate() {
|
||||
const [trafficDiscount, setTrafficDiscount] = useState<number | ''>(0);
|
||||
const [deviceDiscount, setDeviceDiscount] = useState<number | ''>(0);
|
||||
const [applyToAddons, setApplyToAddons] = useState(true);
|
||||
const [isDefault, setIsDefault] = useState(false);
|
||||
const [autoAssignSpent, setAutoAssignSpent] = useState<number | ''>(0);
|
||||
const [periodDiscounts, setPeriodDiscounts] = useState<PeriodDiscount[]>([]);
|
||||
|
||||
@@ -79,6 +80,7 @@ export default function AdminPromoGroupCreate() {
|
||||
setTrafficDiscount(data.traffic_discount_percent || 0);
|
||||
setDeviceDiscount(data.device_discount_percent || 0);
|
||||
setApplyToAddons(data.apply_discounts_to_addons ?? true);
|
||||
setIsDefault(data.is_default ?? false);
|
||||
setAutoAssignSpent(
|
||||
data.auto_assign_total_spent_kopeks ? data.auto_assign_total_spent_kopeks / 100 : 0,
|
||||
);
|
||||
@@ -151,7 +153,8 @@ export default function AdminPromoGroupCreate() {
|
||||
period_discounts:
|
||||
Object.keys(periodDiscountsRecord).length > 0 ? periodDiscountsRecord : undefined,
|
||||
apply_discounts_to_addons: applyToAddons,
|
||||
auto_assign_total_spent_kopeks: autoAssignVal > 0 ? Math.round(autoAssignVal * 100) : null,
|
||||
auto_assign_total_spent_kopeks: autoAssignVal > 0 ? Math.round(autoAssignVal * 100) : 0,
|
||||
is_default: isDefault,
|
||||
};
|
||||
|
||||
if (isEdit) {
|
||||
@@ -388,6 +391,24 @@ export default function AdminPromoGroupCreate() {
|
||||
</button>
|
||||
<span className="text-sm text-dark-200">{t('admin.promoGroups.form.applyToAddons')}</span>
|
||||
</label>
|
||||
|
||||
{/* Default group */}
|
||||
<label className="flex cursor-pointer items-center gap-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsDefault(!isDefault)}
|
||||
className={`relative h-6 w-11 rounded-full transition-colors ${
|
||||
isDefault ? 'bg-accent-500' : 'bg-dark-600'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`absolute top-1 h-4 w-4 rounded-full bg-white transition-transform ${
|
||||
isDefault ? 'left-6' : 'left-1'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
<span className="text-sm text-dark-200">{t('admin.promoGroups.form.isDefault')}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
|
||||
Reference in New Issue
Block a user