diff --git a/backend/src/index.js b/backend/src/index.js index 81b7ba5a..6fa2cb31 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -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')); diff --git a/frontend/src/components/SectionsManager.tsx b/frontend/src/components/SectionsManager.tsx index a4bdf14d..a7c2c499 100644 --- a/frontend/src/components/SectionsManager.tsx +++ b/frontend/src/components/SectionsManager.tsx @@ -171,9 +171,10 @@ const SectionsManager: React.FC = ({ setShowColorPicker(null); }; - const ColorPicker = ({ selectedColor, onSelect, target }: { selectedColor: string; onSelect: (color: string) => void; target: number | 'new' }) => ( -
-
+ const ColorPicker = ({ selectedColor, onSelect }: { selectedColor: string; onSelect: (color: string) => void }) => ( +
+

Choose a color

+
{SECTION_COLORS.map(color => ( ))}
@@ -239,7 +248,6 @@ const SectionsManager: React.FC = ({ )}
@@ -342,7 +350,6 @@ const SectionsManager: React.FC = ({ )}