Mark-Lasfar commited on
Commit ·
7411be7
1
Parent(s): ae31cfd
Fix: Optimize loadStore function, fix preview mode and follow-status
Browse files
server.js
CHANGED
|
@@ -19634,10 +19634,17 @@ app.put('/api/store/sections/order', authenticateToken, async (req, res) => {
|
|
| 19634 |
console.log('SECTIONS FROM CLIENT:', sections);
|
| 19635 |
console.log('CURRENT SECTIONS:', currentSections);
|
| 19636 |
// تحديث الأقسام بالترتيب الجديد
|
| 19637 |
-
const updatedSections = currentSections.map(section =>
|
| 19638 |
-
|
| 19639 |
-
|
| 19640 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19641 |
|
| 19642 |
// حفظ التغييرات
|
| 19643 |
storeSettings.pageBuilder.sections = updatedSections;
|
|
|
|
| 19634 |
console.log('SECTIONS FROM CLIENT:', sections);
|
| 19635 |
console.log('CURRENT SECTIONS:', currentSections);
|
| 19636 |
// تحديث الأقسام بالترتيب الجديد
|
| 19637 |
+
const updatedSections = currentSections.map(section => {
|
| 19638 |
+
// ✅ التحقق من وجود toObject (إذا كان Document)
|
| 19639 |
+
const sectionObj = (section && typeof section.toObject === 'function')
|
| 19640 |
+
? section.toObject()
|
| 19641 |
+
: section;
|
| 19642 |
+
|
| 19643 |
+
return {
|
| 19644 |
+
...sectionObj,
|
| 19645 |
+
order: orderMap.get(section.id) || section.order || 0
|
| 19646 |
+
};
|
| 19647 |
+
});
|
| 19648 |
|
| 19649 |
// حفظ التغييرات
|
| 19650 |
storeSettings.pageBuilder.sections = updatedSections;
|