Support new backend contracts: single-flight refresh, ad impression tokens, error handling

- apiFetch: proactive refresh, cross-tab single-flight via Web Locks, no logout on transient errors
- AuthContext: save tokens returned on own login change, revoke refresh on logout, sync tabs
- Ads: X-Session-Id, impressionToken in impression/click, IAB viewability, safe http(s) targetUrl
- STOMP: refresh before CONNECT, stop reconnect loop on dead session, /user/queue/errors behind flag
- Auth form: password 8 chars / 72 bytes; 429/413 messages via describeApiError
- My posts with auth + moderation badges; post form step validation and field limits
- Map: escape user text in Yandex hint/template

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SlimusMinus
2026-10-20 02:03:42 +03:00
parent 67de963d6d
commit db37befb8d
34 changed files with 1005 additions and 260 deletions

View File

@@ -2,6 +2,7 @@ import { useState, useCallback } from "react";
import { useTranslation } from 'react-i18next';
import { API_URL } from "../config/authConstants";
import { apiFetch } from "../api/apiClient";
import { describeApiError, readApiError } from "../api/apiErrors";
/**
* useUpdateProfile — хук для обновления профиля пользователя.
@@ -53,14 +54,16 @@ export function useUpdateProfile() {
});
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.message || t('profile.updateErrorWithStatus', { status: res.status }));
const apiError = await readApiError(res);
throw new Error(describeApiError(apiError, t('profile.updateErrorWithStatus', { status: res.status })));
}
// При смене своего логина в ответе есть новые token/refreshToken —
// их сохраняет AuthContext.updateUser (старые больше не действуют).
const updatedUser = await res.json();
return { success: true, data: updatedUser, error: null };
} catch (err) {
const message = err.message || t('profile.updateError');
const message = describeApiError(err, t('profile.updateError'));
setError(message);
return { success: false, data: null, error: message };
} finally {