Commit 95d81235 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: notifications broken — select non-existent 'metadata' column

The notifications API selected a column 'metadata' that doesn't exist
in the table (actual column is 'data'). This caused PostgREST to
return an error, which the error handler caught and returned empty.
Users never saw their notifications.

Also added body_ar to the select and frontend display.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 6790db43
......@@ -20,7 +20,7 @@ if ($method === 'GET') {
$limit = intval($_GET['limit'] ?? 50);
$notifications = $db->get('notifications', [
'user_id' => 'eq.' . $userId,
'select' => 'id,type,title,title_ar,body,is_read,created_at,metadata',
'select' => 'id,type,title,title_ar,body,body_ar,is_read,created_at,data',
'order' => 'created_at.desc',
'limit' => $limit
]);
......
......@@ -33,7 +33,7 @@ function renderNotifications(el, notifications) {
list.innerHTML = notifications.map(n => `
<div class="card" style="padding:var(--s-3);margin-bottom:var(--s-2);opacity:${n.is_read ? '0.7' : '1'};">
<div style="font-size:14px;font-weight:${n.is_read ? '400' : '600'};">${n.title_ar || n.title || ''}</div>
<div style="font-size:12px;color:var(--text-secondary);margin-top:2px;">${n.body || ''}</div>
<div style="font-size:12px;color:var(--text-secondary);margin-top:2px;">${n.body_ar || n.body || ''}</div>
<div style="font-size:10px;color:var(--text-muted);margin-top:4px;">${timeAgo(n.created_at)}</div>
</div>
`).join('');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment