Update/add frontend pages for categories, brands, vendors new routes, update products page to use new route

This commit is contained in:
2025-04-01 14:34:57 -04:00
parent 1b9f01d101
commit dbd0232285
18 changed files with 2844 additions and 2619 deletions

View File

@@ -192,7 +192,28 @@ router.get('/', async (req, res) => {
]);
const total = parseInt(countResult.rows[0].total, 10);
const brands = dataResult.rows;
const brands = dataResult.rows.map(row => {
// Create a new object with both snake_case and camelCase keys
const transformedRow = { ...row }; // Start with original data
for (const key in row) {
// Skip null/undefined values
if (row[key] === null || row[key] === undefined) {
continue; // Original already has the null value
}
// Transform keys to match frontend expectations (add camelCase versions)
// First handle cases like sales_7d -> sales7d
let camelKey = key.replace(/_(\d+[a-z])/g, '$1');
// Then handle regular snake_case -> camelCase
camelKey = camelKey.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
if (camelKey !== key) { // Only add if different from original
transformedRow[camelKey] = row[key];
}
}
return transformedRow;
});
// --- Respond ---
res.json({