function registerClientSuccessRoutes(app, { clientSuccess }) {
  app.get('/api/success-loops/:divisionId', (req, res) => {
    res.json({ loops: clientSuccess.listSuccessLoops(Number(req.params.divisionId) || 6) });
  });

  app.post('/api/success-loops', (req, res) => {
    const id = clientSuccess.insertSuccessLoop(req.body || {});
    res.json({ id });
  });

  app.put('/api/success-loops/:id', (req, res) => {
    const success = clientSuccess.updateSuccessLoop(Number(req.params.id), req.body || {});
    if (!success) return res.status(404).json({ error: 'Success loop not found' });
    res.json({ success: true });
  });

  app.delete('/api/success-loops/:id', (req, res) => {
    clientSuccess.deleteSuccessLoop(Number(req.params.id));
    res.json({ success: true });
  });
}

module.exports = { registerClientSuccessRoutes };
