mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
feat: add blacklisted user blocking screen
Add BlacklistedScreen component, blocking store type, API error interceptor, and i18n translations (ru, en, zh, fa) for blacklisted users.
This commit is contained in:
@@ -111,6 +111,11 @@ export interface ChannelSubscriptionError {
|
||||
channel_link?: string;
|
||||
}
|
||||
|
||||
export interface BlacklistedError {
|
||||
code: 'blacklisted';
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function isMaintenanceError(
|
||||
error: unknown,
|
||||
): error is { response: { status: 503; data: { detail: MaintenanceError } } } {
|
||||
@@ -130,6 +135,14 @@ export function isChannelSubscriptionError(
|
||||
);
|
||||
}
|
||||
|
||||
export function isBlacklistedError(
|
||||
error: unknown,
|
||||
): error is { response: { status: 403; data: { detail: BlacklistedError } } } {
|
||||
if (!error || typeof error !== 'object') return false;
|
||||
const err = error as AxiosError<{ detail: BlacklistedError }>;
|
||||
return err.response?.status === 403 && err.response?.data?.detail?.code === 'blacklisted';
|
||||
}
|
||||
|
||||
// Response interceptor - handle 401, 503 (maintenance), 403 (channel subscription)
|
||||
apiClient.interceptors.response.use(
|
||||
(response) => response,
|
||||
@@ -156,6 +169,15 @@ apiClient.interceptors.response.use(
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
// Handle blacklisted user (403)
|
||||
if (isBlacklistedError(error)) {
|
||||
const detail = (error.response?.data as { detail: BlacklistedError }).detail;
|
||||
useBlockingStore.getState().setBlacklisted({
|
||||
message: detail.message,
|
||||
});
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
// Если получили 401 и ещё не пробовали refresh (на случай если проверка exp не сработала)
|
||||
if (error.response?.status === 401 && !originalRequest._retry) {
|
||||
// Не обрабатываем 401 для авторизационных endpoints - пусть ошибка дойдет до компонента
|
||||
|
||||
Reference in New Issue
Block a user