mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
feat: migrate Telegram Login Widget to v23 with admin-configurable settings
- Upgrade telegram-widget.js from v22 to v23 (TelegramLoginButton + ConnectedAccounts) - TelegramLoginButton fetches widget config from API instead of hardcoded values - Add TelegramWidgetConfig type and API method with fallback to env defaults - Remove botUsername prop — now sourced from backend API - Add useEffect cleanup to prevent orphaned iframes on unmount - Add TELEGRAM_WIDGET category to admin interface settings menu - Add i18n translations for widget settings (ru, en, zh, fa)
This commit is contained in:
@@ -23,6 +23,14 @@ export interface EmailAuthEnabled {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface TelegramWidgetConfig {
|
||||
bot_username: string;
|
||||
size: 'large' | 'medium' | 'small';
|
||||
radius: number;
|
||||
userpic: boolean;
|
||||
request_access: boolean;
|
||||
}
|
||||
|
||||
export interface AnalyticsCounters {
|
||||
yandex_metrika_id: string;
|
||||
google_ads_id: string;
|
||||
@@ -251,6 +259,24 @@ export const brandingApi = {
|
||||
}
|
||||
},
|
||||
|
||||
// Get Telegram widget config (public, no auth required)
|
||||
getTelegramWidgetConfig: async (): Promise<TelegramWidgetConfig> => {
|
||||
try {
|
||||
const response = await apiClient.get<TelegramWidgetConfig>(
|
||||
'/cabinet/branding/telegram-widget',
|
||||
);
|
||||
return response.data;
|
||||
} catch {
|
||||
return {
|
||||
bot_username: import.meta.env.VITE_TELEGRAM_BOT_USERNAME || '',
|
||||
size: 'large',
|
||||
radius: 8,
|
||||
userpic: true,
|
||||
request_access: true,
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// Update analytics counters (admin only)
|
||||
updateAnalyticsCounters: async (data: Partial<AnalyticsCounters>): Promise<AnalyticsCounters> => {
|
||||
const response = await apiClient.patch<AnalyticsCounters>('/cabinet/branding/analytics', data);
|
||||
|
||||
Reference in New Issue
Block a user