Fix credit accounting popup sending to wrong API endpoint

saveCreditEntry and deleteCreditEntry were using apiFetch() which routes
to /api/admin.php, but credits_create/update/delete only exist in
/api/platforms.php — causing the Unknown action error on every save.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 21:27:53 +00:00
parent b6adb7a3f0
commit 1367fa334b
+2 -2
View File
@@ -3232,7 +3232,7 @@ async function saveCreditEntry() {
const payload = entryId
? {id:parseInt(entryId),credits_purchased:credits,credit_date:date,payment_method:method,notes}
: {platform_id:_creditPlatformId,credits_purchased:credits,credit_date:date,payment_method:method,notes};
const d = await apiFetch(action,'POST',payload);
const d = await fetch(`/api/platforms.php?action=${action}`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(payload)}).then(r=>r.json());
if (d.success) {
showAdminAlert(al, entryId ? 'Entry updated!' : 'Entry added!', 'success');
resetCreditForm();
@@ -3244,7 +3244,7 @@ async function saveCreditEntry() {
async function deleteCreditEntry(id) {
if (!confirm('Delete this credit entry? This cannot be undone.')) return;
const d = await apiFetch('credits_delete','POST',{id});
const d = await fetch('/api/platforms.php?action=credits_delete',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({id})}).then(r=>r.json());
if (d.success) { toast('Entry deleted','ok'); await loadCreditEntries(); }
else toast(d.error||'Error','err');
}