fix(newsletter): convert ObjectId to string in DELETE button data attributes

Root cause: MongoDB ObjectId objects were being inserted into data-id
attributes as '[object Object]' instead of their string representation.

Fix: Explicitly call String() on sub._id when creating data attributes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TheFlow 2025-10-24 20:24:54 +13:00
parent 0b807a8bc0
commit c0bc35f2de
2 changed files with 3 additions and 3 deletions

View file

@ -110,7 +110,7 @@
</div>
<script src="/js/admin/newsletter-management.js?v=0.1.1.newsletter-delete-fix"></script>
<script src="/js/admin/newsletter-management.js?v=0.1.2.objectid-to-string"></script>
</body>
</html>

View file

@ -147,8 +147,8 @@ function renderSubscribers(subscriptions) {
${formatDate(sub.subscribed_at)}
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button class="view-details-btn text-blue-600 hover:text-blue-900 mr-3" data-id="${sub._id}">View</button>
<button class="delete-subscriber-btn text-red-600 hover:text-red-900" data-id="${sub._id}" data-email="${escapeHtml(sub.email)}">Delete</button>
<button class="view-details-btn text-blue-600 hover:text-blue-900 mr-3" data-id="${String(sub._id)}">View</button>
<button class="delete-subscriber-btn text-red-600 hover:text-red-900" data-id="${String(sub._id)}" data-email="${escapeHtml(sub.email)}">Delete</button>
</td>
</tr>
`).join('');