feat(websocket): add global handler for subscription and balance notifications

- Extend WSMessage interface with balance, subscription, autopay, account, referral fields
- Create WebSocketNotifications component to handle all WS events
- Add component to Layout for global event listening
- Show toasts and invalidate queries on subscription/balance events
- Add translations for all notification types (ru, en, zh, fa)
This commit is contained in:
c0mrade
2026-01-30 19:04:45 +03:00
parent cb57c34b55
commit ca227f3975
7 changed files with 637 additions and 1 deletions

View File

@@ -5,11 +5,37 @@ const isDev = import.meta.env.DEV;
export interface WSMessage {
type: string;
// Ticket events
ticket_id?: number;
message?: string;
title?: string;
// Common
message?: string;
user_id?: number;
is_admin?: boolean;
// Balance events
amount_kopeks?: number;
amount_rubles?: number;
new_balance_kopeks?: number;
new_balance_rubles?: number;
description?: string;
// Subscription events
expires_at?: string;
new_expires_at?: string;
tariff_name?: string;
days_left?: number;
// Autopay events
required_kopeks?: number;
required_rubles?: number;
balance_kopeks?: number;
balance_rubles?: number;
reason?: string;
// Account events (ban/warning)
// Referral events
bonus_kopeks?: number;
bonus_rubles?: number;
referral_name?: string;
// Payment events
payment_method?: string;
}
interface UseWebSocketOptions {