fix: ClosedCases — apiFetch возвращает Response, а не JSON (архив всегда показывал 0)
- Загрузка списка, создание и удаление переведены на apiJson (apiFetch → Response.items === undefined → items=[]).
This commit is contained in:
@@ -138,9 +138,8 @@ export default function ClosedCases() {
|
|||||||
}
|
}
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
const created = await apiFetch('/api/v1/closed-cases', {
|
const created = await apiJson('/api/v1/closed-cases', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify(CleanForm(form)),
|
body: JSON.stringify(CleanForm(form)),
|
||||||
});
|
});
|
||||||
setLastPrediction(created);
|
setLastPrediction(created);
|
||||||
@@ -156,7 +155,7 @@ export default function ClosedCases() {
|
|||||||
const remove = async (id) => {
|
const remove = async (id) => {
|
||||||
if (!window.confirm('Удалить запись?')) return;
|
if (!window.confirm('Удалить запись?')) return;
|
||||||
try {
|
try {
|
||||||
await apiFetch(`/api/v1/closed-cases/${id}`, { method: 'DELETE' });
|
await apiJson(`/api/v1/closed-cases/${id}`, { method: 'DELETE' });
|
||||||
await load();
|
await load();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(e.message);
|
setError(e.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user