Browse Source

feat(frontend): add delete functionality for ad feed items and run history records

master
PouyaKhajavi 1 day ago
parent
commit
e28e24e5dd
  1. 40
      frontend/src/App.jsx

40
frontend/src/App.jsx

@ -294,6 +294,29 @@ function App() {
}
};
const deleteAd = async (id) => {
if (!confirm('آیا از حذف این آگهی اطمینان دارید؟')) return;
try {
await axios.delete(`/api/ads/${id}/`);
showToast('آگهی با موفقیت حذف شد', 'success');
setAds(prev => prev.filter(item => item.id !== id));
} catch (err) {
showToast('خطا در حذف آگهی', 'danger');
}
};
const deleteRun = async (id) => {
if (!confirm('آیا از حذف این سابقه اجرا اطمینان دارید؟')) return;
try {
await axios.delete(`/api/crawlers/runs/${id}/`);
showToast('سابقه اجرا با موفقیت حذف شد', 'success');
setLogs(prev => prev.filter(item => item.id !== id));
} catch (err) {
showToast('خطا در حذف سابقه اجرا', 'danger');
}
};
// Format date helper
const formatDate = (isoStr) => {
if (!isoStr) return '-';
@ -584,6 +607,13 @@ function App() {
<a href={adEval.ad.url} target="_blank" rel="noopener noreferrer" className="inline-flex items-center justify-center border rounded-lg p-2 text-sm font-medium cursor-pointer transition-all duration-200 bg-white/5 border-white/5 text-blue-400 hover:bg-white/10" title="مشاهده در دیوار">
<ExternalLink className="w-5 h-5" />
</a>
<button
onClick={() => deleteAd(adEval.id)}
className="inline-flex items-center justify-center border rounded-lg p-2 text-sm font-medium cursor-pointer transition-all duration-200 bg-rose-500/10 border-rose-500/20 text-rose-400 hover:bg-rose-500/20"
title="حذف آگهی"
>
<Trash2 className="w-5 h-5" />
</button>
</div>
</div>
))}
@ -618,6 +648,7 @@ function App() {
<th className="px-5 py-4 border-b border-white/5">پردازش AI</th>
<th className="px-5 py-4 border-b border-white/5">پرچم‌گذاری شده</th>
<th className="px-5 py-4 border-b border-white/5">لاگ خطا</th>
<th className="px-5 py-4 border-b border-white/5 text-center">عملیات</th>
</tr>
</thead>
<tbody>
@ -645,6 +676,15 @@ function App() {
>
{run.error_log || '-'}
</td>
<td className="px-5 py-4 border-b border-white/5 text-center">
<button
onClick={() => deleteRun(run.id)}
className="inline-flex items-center justify-center p-1.5 rounded-lg bg-rose-500/10 border border-rose-500/20 text-rose-400 hover:bg-rose-500/20 transition-all duration-200"
title="حذف سابقه اجرا"
>
<Trash2 className="w-4 h-4" />
</button>
</td>
</tr>
))}
</tbody>

Loading…
Cancel
Save