fix(autocall): блок «Автодозвон» не появлялся в карточке, если порядок блоков сохранён в localStorage — мердж с дефолтом
This commit is contained in:
parent
c7a35cdd29
commit
f378fd05ef
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue