Files
bedolaga-cabinet/src/store/blocking.ts
Fringg 5a8c1e7e33 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.
2026-02-06 15:48:24 +03:00

69 lines
1.5 KiB
TypeScript

import { create } from 'zustand';
export type BlockingType = 'maintenance' | 'channel_subscription' | 'blacklisted' | null;
interface MaintenanceInfo {
message: string;
reason?: string;
}
interface ChannelSubscriptionInfo {
message: string;
channel_link?: string;
}
interface BlacklistedInfo {
message: string;
}
interface BlockingState {
blockingType: BlockingType;
maintenanceInfo: MaintenanceInfo | null;
channelInfo: ChannelSubscriptionInfo | null;
blacklistedInfo: BlacklistedInfo | null;
setMaintenance: (info: MaintenanceInfo) => void;
setChannelSubscription: (info: ChannelSubscriptionInfo) => void;
setBlacklisted: (info: BlacklistedInfo) => void;
clearBlocking: () => void;
}
export const useBlockingStore = create<BlockingState>((set) => ({
blockingType: null,
maintenanceInfo: null,
channelInfo: null,
blacklistedInfo: null,
setMaintenance: (info) =>
set({
blockingType: 'maintenance',
maintenanceInfo: info,
channelInfo: null,
blacklistedInfo: null,
}),
setChannelSubscription: (info) =>
set({
blockingType: 'channel_subscription',
channelInfo: info,
maintenanceInfo: null,
blacklistedInfo: null,
}),
setBlacklisted: (info) =>
set({
blockingType: 'blacklisted',
blacklistedInfo: info,
maintenanceInfo: null,
channelInfo: null,
}),
clearBlocking: () =>
set({
blockingType: null,
maintenanceInfo: null,
channelInfo: null,
blacklistedInfo: null,
}),
}));