fix(autocall): блок «Автодозвон» не появлялся в карточке, если порядок блоков сохранён в localStorage — мердж с дефолтом

This commit is contained in:
Hermes 2026-09-10 11:32:14 +02:00
parent c7a35cdd29
commit f378fd05ef
1 changed files with 13 additions and 3 deletions

View File

@ -689,11 +689,21 @@ export const OrderDetailPanel = ({
// ---- Drag-and-drop block reordering state ---- // ---- Drag-and-drop block reordering state ----
const isLogisticsRole = ["manager", "logistician", "admin", "mega_admin"].includes(userRole); const isLogisticsRole = ["manager", "logistician", "admin", "mega_admin"].includes(userRole);
const [blockOrder, setBlockOrder] = React.useState(() => { const [blockOrder, setBlockOrder] = React.useState(() => {
let saved = null;
try { try {
const saved = JSON.parse(localStorage.getItem(ORDER_STORAGE_KEY) || "[]"); const parsed = JSON.parse(localStorage.getItem(ORDER_STORAGE_KEY) || "[]");
if (Array.isArray(saved) && saved.length > 0) return saved; if (Array.isArray(parsed) && parsed.length > 0) saved = parsed;
} catch {} } catch {}
return DEFAULT_BLOCK_ORDER; if (!saved) return DEFAULT_BLOCK_ORDER;
// Мердж с дефолтом: новые блоки (например, autocall_status) добавляются,
// устаревшие ключи удаляются — иначе сохранённый порядок навсегда скрывает новые блоки.
const merged = [
// сначала сохранённые ключи, которые ещё актуальны
...saved.filter((k) => DEFAULT_BLOCK_ORDER.includes(k)),
// затем новые блоки, которых нет в сохранённом — вставляем рядом со «Статус SMS»
...DEFAULT_BLOCK_ORDER.filter((k) => !saved.includes(k)),
];
return merged;
}); });
const [activeTab, setActiveTab] = React.useState(() => { const [activeTab, setActiveTab] = React.useState(() => {
try { try {