Colors and ordering fix
This commit is contained in:
@@ -492,6 +492,22 @@ app.post('/api/sections', requireAuth, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// IMPORTANT: /reorder must come BEFORE /:id to avoid matching "reorder" as an id
|
||||
app.put('/api/sections/reorder', requireAuth, (req, res) => {
|
||||
const { sectionIds } = req.body;
|
||||
|
||||
if (!Array.isArray(sectionIds)) {
|
||||
return res.status(400).json({ error: 'sectionIds must be an array' });
|
||||
}
|
||||
|
||||
sectionsOps.reorderSections(req.user.id, sectionIds, (err) => {
|
||||
if (err) {
|
||||
return res.status(500).json({ error: 'Failed to reorder sections' });
|
||||
}
|
||||
res.json({ message: 'Sections reordered successfully' });
|
||||
});
|
||||
});
|
||||
|
||||
app.put('/api/sections/:id', requireAuth, (req, res) => {
|
||||
const sectionId = req.params.id;
|
||||
const { name, color, is_default } = req.body;
|
||||
@@ -518,21 +534,6 @@ app.delete('/api/sections/:id', requireAuth, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.put('/api/sections/reorder', requireAuth, (req, res) => {
|
||||
const { sectionIds } = req.body;
|
||||
|
||||
if (!Array.isArray(sectionIds)) {
|
||||
return res.status(400).json({ error: 'sectionIds must be an array' });
|
||||
}
|
||||
|
||||
sectionsOps.reorderSections(req.user.id, sectionIds, (err) => {
|
||||
if (err) {
|
||||
return res.status(500).json({ error: 'Failed to reorder sections' });
|
||||
}
|
||||
res.json({ message: 'Sections reordered successfully' });
|
||||
});
|
||||
});
|
||||
|
||||
// Catch-all handler: send back React's index.html for client-side routing
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../../frontend/build/index.html'));
|
||||
|
||||
Reference in New Issue
Block a user