mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
feat: show MULTI_TARIFF_ENABLED setting only in tariffs sales mode
Hide MULTI_TARIFF_ENABLED and MAX_ACTIVE_SUBSCRIPTIONS from admin settings when SALES_MODE is not 'tariffs'. Add Russian translations.
This commit is contained in:
@@ -2255,6 +2255,8 @@
|
|||||||
"Devices Selection Enabled": "Выбор устройств",
|
"Devices Selection Enabled": "Выбор устройств",
|
||||||
"Max Devices Limit": "Макс. устройств",
|
"Max Devices Limit": "Макс. устройств",
|
||||||
"Price Per Device": "Цена за устройство",
|
"Price Per Device": "Цена за устройство",
|
||||||
|
"Multi Tariff Enabled": "Мультитарифный режим",
|
||||||
|
"Max Active Subscriptions": "Макс. подписок",
|
||||||
"Sales Mode": "Режим продаж",
|
"Sales Mode": "Режим продаж",
|
||||||
"Available Renewal Periods": "Периоды продления",
|
"Available Renewal Periods": "Периоды продления",
|
||||||
"Available Subscription Periods": "Периоды подписки",
|
"Available Subscription Periods": "Периоды подписки",
|
||||||
|
|||||||
@@ -85,6 +85,16 @@ export default function AdminSettings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settings that require SALES_MODE=tariffs to be visible
|
||||||
|
const TARIFF_MODE_SETTINGS = ['MULTI_TARIFF_ENABLED', 'MAX_ACTIVE_SUBSCRIPTIONS'];
|
||||||
|
|
||||||
|
// Check if tariffs mode is active
|
||||||
|
const isTariffsMode = useMemo(() => {
|
||||||
|
if (!allSettings || !Array.isArray(allSettings)) return false;
|
||||||
|
const salesMode = allSettings.find((s: SettingDefinition) => s.key === 'SALES_MODE');
|
||||||
|
return salesMode?.current === 'tariffs';
|
||||||
|
}, [allSettings]);
|
||||||
|
|
||||||
// Get categories for current sub-item
|
// Get categories for current sub-item
|
||||||
const currentCategories = useMemo(() => {
|
const currentCategories = useMemo(() => {
|
||||||
if (!activeTreeInfo || !allSettings || !Array.isArray(allSettings)) return [];
|
if (!activeTreeInfo || !allSettings || !Array.isArray(allSettings)) return [];
|
||||||
@@ -94,6 +104,9 @@ export default function AdminSettings() {
|
|||||||
|
|
||||||
for (const setting of allSettings) {
|
for (const setting of allSettings) {
|
||||||
if (categoryKeys.includes(setting.category.key)) {
|
if (categoryKeys.includes(setting.category.key)) {
|
||||||
|
// Hide tariff-dependent settings when not in tariffs mode
|
||||||
|
if (!isTariffsMode && TARIFF_MODE_SETTINGS.includes(setting.key)) continue;
|
||||||
|
|
||||||
if (!categoryMap.has(setting.category.key)) {
|
if (!categoryMap.has(setting.category.key)) {
|
||||||
categoryMap.set(setting.category.key, []);
|
categoryMap.set(setting.category.key, []);
|
||||||
}
|
}
|
||||||
@@ -107,7 +120,7 @@ export default function AdminSettings() {
|
|||||||
settings,
|
settings,
|
||||||
}));
|
}));
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- activeTreeInfo derived from activeSection
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- activeTreeInfo derived from activeSection
|
||||||
}, [activeSection, allSettings, t]);
|
}, [activeSection, allSettings, isTariffsMode, t]);
|
||||||
|
|
||||||
// Filter settings for search - GLOBAL search across all settings
|
// Filter settings for search - GLOBAL search across all settings
|
||||||
const filteredSettings = useMemo(() => {
|
const filteredSettings = useMemo(() => {
|
||||||
@@ -117,6 +130,9 @@ export default function AdminSettings() {
|
|||||||
if (!q) return [];
|
if (!q) return [];
|
||||||
|
|
||||||
return allSettings.filter((s: SettingDefinition) => {
|
return allSettings.filter((s: SettingDefinition) => {
|
||||||
|
// Hide tariff-dependent settings when not in tariffs mode
|
||||||
|
if (!isTariffsMode && TARIFF_MODE_SETTINGS.includes(s.key)) return false;
|
||||||
|
|
||||||
if (s.key.toLowerCase().includes(q)) return true;
|
if (s.key.toLowerCase().includes(q)) return true;
|
||||||
if (s.name?.toLowerCase().includes(q)) return true;
|
if (s.name?.toLowerCase().includes(q)) return true;
|
||||||
const formattedKey = formatSettingKey(s.name || s.key);
|
const formattedKey = formatSettingKey(s.name || s.key);
|
||||||
@@ -127,7 +143,7 @@ export default function AdminSettings() {
|
|||||||
if (categoryLabel.toLowerCase().includes(q)) return true;
|
if (categoryLabel.toLowerCase().includes(q)) return true;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}, [allSettings, searchQuery, t]);
|
}, [allSettings, searchQuery, isTariffsMode, t]);
|
||||||
|
|
||||||
// Favorite settings
|
// Favorite settings
|
||||||
const favoriteSettings = useMemo(() => {
|
const favoriteSettings = useMemo(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user