This commit is contained in:
Jake Kasper
2025-09-05 10:33:58 -04:00
parent af10a60e17
commit e691172a9c
3 changed files with 225 additions and 18 deletions

View File

@@ -60,6 +60,28 @@ router.post('/plans', async (req, res, next) => {
} catch (e) { next(e); }
});
// PUT /api/watering/plans/:id - rename/update notes
router.put('/plans/:id', async (req, res, next) => {
try {
const planId = req.params.id;
// Verify ownership
const own = await pool.query('SELECT id FROM watering_plans WHERE id=$1 AND user_id=$2', [planId, req.user.id]);
if (own.rows.length === 0) throw new AppError('Plan not found', 404);
const { name, notes } = req.body || {};
const rs = await pool.query(
`UPDATE watering_plans
SET name = COALESCE($1, name),
notes = COALESCE($2, notes),
updated_at = NOW()
WHERE id=$3
RETURNING *`,
[name, notes, planId]
);
res.json({ success: true, data: { plan: rs.rows[0] } });
} catch (e) { next(e); }
});
// GET /api/watering/plans/:id/points
router.get('/plans/:id/points', async (req, res, next) => {
try {