diff --git a/public/js/feedback.js b/public/js/feedback.js index 5f2bb27..627c664 100644 --- a/public/js/feedback.js +++ b/public/js/feedback.js @@ -433,8 +433,9 @@ const r = await fetch(`${API}/api/feedbacks/last?resident=${encodeURIComponent(resident)}`, { headers: hdr() }); if (r.ok) { const row = await r.json(); - if (row && row.text) document.getElementById('fbPastReview').value = row.text; - setPastReviewLabel(row && row.text ? row : null); + const found = row && row.text ? row : null; + document.getElementById('fbPastReview').value = found ? found.text : ''; + setPastReviewLabel(found); } } catch (e) {} } diff --git a/server.js b/server.js index 5d1286b..a2b4f77 100644 --- a/server.js +++ b/server.js @@ -2985,7 +2985,7 @@ app.get('/api/feedbacks/last', requireAuth, async (req, res) => { const bs = branchScope(req.user); if (bs.ids && !bs.ids.length) return null; const params = [`%${resident}%`]; - let cond = 'f.deleted_at IS NULL AND f.resident ILIKE $1'; + let cond = 'f.deleted_at IS NULL AND f.sent_at IS NOT NULL AND f.resident ILIKE $1'; if (bs.ids) { params.push(bs.ids); cond += ` AND f.branch_id = ANY($${params.length}::int[])`; } const { rows } = await pool.query( `SELECT f.id, f.feedback_date, f.group_id, f.resident, f.topic, f.past_review, f.text, f.ai_status, f.sent_at, f.branch_id, f.deleted_at, g.name AS group_name