fixed code

This commit is contained in:
SlimusMinus
2026-08-11 00:24:07 +03:00
parent c50b75eece
commit 7f59ee1f38
95 changed files with 3623 additions and 2830 deletions

View File

@@ -1,4 +1,5 @@
import { useState } from "react";
import { useTranslation } from 'react-i18next';
import { API_URL } from "../config/authConstants";
import { apiFetch } from "../api/apiClient";
@@ -19,6 +20,7 @@ import { apiFetch } from "../api/apiClient";
* null — серверная ошибка (свойство error содержит текст)
*/
export function usePostMutation() {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const [error, setError] = useState("");
@@ -46,12 +48,12 @@ export function usePostMutation() {
return { blocked: true, reason: body.reason || "" };
}
throw new Error(body?.message || `Ошибка сервера: ${res.status}`);
throw new Error(body?.message || t('post.serverError', { status: res.status }));
}
return { data: await res.json() };
} catch (e) {
setError(e.message || "Неизвестная ошибка");
setError(e.message || t('post.unknownError'));
return null;
} finally {
setLoading(false);