import React, { ChangeEvent } from 'react'; import { useTranslation } from 'react-i18next'; import { InformationCircleIcon, CogIcon, ClipboardDocumentListIcon, } from '@heroicons/react/24/outline'; import TelegramIcon from '../../Shared/Icons/TelegramIcon'; import type { Profile, ProfileFormData, TelegramBotInfo } from '../types'; interface TelegramTabProps { isActive: boolean; formData: ProfileFormData; profile: Profile | null; telegramBotInfo: TelegramBotInfo | null; isPolling: boolean; telegramSetupStatus: 'idle' | 'loading' | 'success' | 'error'; onChange: (e: ChangeEvent) => void; onSetup: () => void; onStartPolling: () => void; onStopPolling: () => void; onToggleSummary: () => void; onSelectFrequency: (frequency: string) => void; onSendTestSummary: () => void; formatFrequency: (frequency: string) => string; } const TelegramTab: React.FC = ({ isActive, formData, profile, telegramBotInfo, isPolling, telegramSetupStatus, onChange, onSetup, onStartPolling, onStopPolling, onToggleSummary, onSelectFrequency, onSendTestSummary, formatFrequency, }) => { const { t } = useTranslation(); if (!isActive) return null; return (

{t('profile.telegramIntegration', 'Telegram Integration')}

{t('profile.botSetup', 'Bot Setup')}

{t( 'profile.telegramDescription', 'Connect your tududi account to a Telegram bot to add items to your inbox via Telegram messages.' )}

{t( 'profile.telegramTokenDescription', 'Create a bot with @BotFather on Telegram and paste the token here.' )}

{t( 'profile.telegramAllowedUsersDescription', 'Control who can send messages to your bot. Leave empty to allow all users.' )}

{t('profile.examples', 'Examples:')}

  • @alice, @bob {' - '} {t( 'profile.exampleUsernames', 'Allow specific usernames' )}
  • 123456789, 987654321 {' - '} {t( 'profile.exampleUserIds', 'Allow specific user IDs' )}
  • @alice, 123456789 {' - '} {t( 'profile.exampleMixed', 'Mix usernames and user IDs' )}
{profile?.telegram_chat_id && (

{t( 'profile.telegramConnected', 'Your Telegram account is connected! Send messages to your bot to add items to your tududi inbox.' )}

)} {(telegramBotInfo || profile?.telegram_bot_token) && (

{t( 'profile.botConfigured', 'Bot configured successfully!' )}

{telegramBotInfo?.first_name && (

Bot Name:{' '} {telegramBotInfo.first_name}

)} {telegramBotInfo?.username && (

{t( 'profile.botUsername', 'Bot Username:' )}{' '} @{telegramBotInfo.username}

)}

{t( 'profile.pollingStatus', 'Polling Status:' )}{' '}

{isPolling ? t('profile.pollingActive') : t('profile.pollingInactive')}

{t( 'profile.pollingNote', 'Polling periodically checks for new messages from Telegram and adds them to your inbox.' )}

{isPolling ? ( ) : ( )} {telegramBotInfo?.chat_url && ( {t( 'profile.openTelegram', 'Open in Telegram' )} )}
)} {telegramSetupStatus === 'success' && (
{t( 'profile.botConfigured', 'Bot configured successfully!' )}
)} {telegramSetupStatus === 'error' && (
{t( 'profile.telegramSetupFailed', 'Setup failed. Please check your token.' )}
)}

{t( 'profile.taskSummaryNotifications', 'Task Summary Notifications' )}

{t( 'profile.taskSummaryDescription', 'Receive regular summaries of your tasks via Telegram. This feature requires your Telegram integration to be set up.' )}

{['1h', '2h', '4h', '8h', '12h', 'daily', 'weekly'].map( (frequency) => ( ) )}

{t( 'profile.frequencyHelp', 'Choose how often you want to receive task summaries.' )}

{(!profile?.telegram_bot_token || !profile?.telegram_chat_id) && (

{t( 'profile.telegramRequiredForSummaries', 'Telegram integration must be set up to use task summaries.' )}

)}
); }; export default TelegramTab;