fix: final review wave — public routes, inbox 419, url schemes, deep_link, tests
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
(() => {
|
||||
const csrf = document.querySelector('meta[name=csrf-token]').content;
|
||||
const call = (method, url, body) => fetch(url, {
|
||||
method, headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-CSRF-TOKEN': csrf },
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
});
|
||||
const call = async (method, url, body) => {
|
||||
const r = await fetch(url, {
|
||||
method, headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-CSRF-TOKEN': csrf },
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
});
|
||||
if (r.status === 419) { location.reload(); return r; }
|
||||
return r;
|
||||
};
|
||||
const showErr = async (el, r) => {
|
||||
const d = await r.json().catch(() => ({}));
|
||||
el.textContent = d.message || Object.values(d.errors || {}).flat().join(' ') || 'Ошибка';
|
||||
@@ -49,7 +53,10 @@
|
||||
const card = btn.closest('.card');
|
||||
card.querySelectorAll('button').forEach(b => b.disabled = true);
|
||||
const r = await call('POST', `/me/events/${card.dataset.id}/${btn.dataset.action}`);
|
||||
if (r.ok) location.reload(); else card.querySelectorAll('button').forEach(b => b.disabled = false);
|
||||
if (r.ok) location.reload(); else if (r.status !== 419) {
|
||||
card.querySelectorAll('button').forEach(b => b.disabled = false);
|
||||
showErr(document.getElementById('card-err'), r);
|
||||
}
|
||||
}));
|
||||
|
||||
// Настройки
|
||||
|
||||
Reference in New Issue
Block a user