Mark-Lasfar commited on
Commit ·
a978d80
1
Parent(s): 7411be7
Fix: Optimize loadStore function, fix preview mode and follow-status
Browse files
server.js
CHANGED
|
@@ -30128,13 +30128,27 @@ app.get('/api/store/:username', async (req, res) => {
|
|
| 30128 |
.sort({ createdAt: -1 })
|
| 30129 |
.limit(50);
|
| 30130 |
|
| 30131 |
-
const
|
| 30132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30133 |
const totalSales = await Order.aggregate([
|
| 30134 |
{ $match: { sellerId: user._id, status: 'completed' } },
|
| 30135 |
{ $group: { _id: null, total: { $sum: '$totalAmount' } } }
|
| 30136 |
]);
|
| 30137 |
-
|
| 30138 |
const productsCount = await Product.countDocuments({ userId: user._id, isActive: true });
|
| 30139 |
const followersCount = await StoreFollow.countDocuments({ storeId: user._id });
|
| 30140 |
|
|
|
|
| 30128 |
.sort({ createdAt: -1 })
|
| 30129 |
.limit(50);
|
| 30130 |
|
| 30131 |
+
const rawSections = storeSettings.pageBuilder?.sections || [];
|
| 30132 |
+
|
| 30133 |
+
// ترتيب الأقسام حسب order
|
| 30134 |
+
const sections = rawSections
|
| 30135 |
+
.map(section => ({
|
| 30136 |
+
id: section.id,
|
| 30137 |
+
type: section.type,
|
| 30138 |
+
enabled: section.enabled !== false,
|
| 30139 |
+
order: section.order || 0,
|
| 30140 |
+
title: section.title || null,
|
| 30141 |
+
limit: section.limit || null,
|
| 30142 |
+
layout: section.layout || null,
|
| 30143 |
+
content: section.content || {}
|
| 30144 |
+
}))
|
| 30145 |
+
.sort((a, b) => (a.order || 0) - (b.order || 0));
|
| 30146 |
+
|
| 30147 |
const totalSales = await Order.aggregate([
|
| 30148 |
{ $match: { sellerId: user._id, status: 'completed' } },
|
| 30149 |
{ $group: { _id: null, total: { $sum: '$totalAmount' } } }
|
| 30150 |
]);
|
| 30151 |
+
|
| 30152 |
const productsCount = await Product.countDocuments({ userId: user._id, isActive: true });
|
| 30153 |
const followersCount = await StoreFollow.countDocuments({ storeId: user._id });
|
| 30154 |
|