@@ -10,9 +10,11 @@ import { PasswordInput } from '@/components/ui/password-input'
1010import { Switch } from '@/components/ui/switch'
1111import { Separator } from '@/components/ui/separator'
1212import { Select , SelectContent , SelectItem , SelectTrigger , SelectValue } from '@/components/ui/select'
13- import { Bot , Webhook , Shield , Globe , Smartphone , Send , Users , Settings } from 'lucide-react'
13+ import { Bot , Webhook , Shield , Globe , Smartphone , Send , Users , Settings , RefreshCcw } from 'lucide-react'
1414import { useSettingsContext } from './_dashboard.settings'
1515import { toast } from 'sonner'
16+ import { Popover , PopoverContent , PopoverTrigger } from '@/components/ui/popover'
17+ import { useState } from 'react'
1618
1719// Telegram settings validation schema
1820const telegramSettingsSchema = z . object ( {
@@ -58,6 +60,13 @@ const telegramSettingsSchema = z.object({
5860
5961type TelegramSettingsForm = z . infer < typeof telegramSettingsSchema >
6062
63+ // Helper function to get current panel URL
64+ const getCurrentPanelUrl = ( ) => {
65+ const protocol = window . location . protocol
66+ const host = window . location . host
67+ return `${ protocol } //${ host } `
68+ }
69+
6170// Helper to map frontend Telegram form data to backend payload
6271function mapTelegramFormToPayload ( data : TelegramSettingsForm ) {
6372 const mapped = {
@@ -76,6 +85,7 @@ function mapTelegramFormToPayload(data: TelegramSettingsForm) {
7685export default function TelegramSettings ( ) {
7786 const { t } = useTranslation ( )
7887 const { settings, isLoading, error, updateSettings, isSaving } = useSettingsContext ( )
88+ const [ popoverOpen , setPopoverOpen ] = useState ( false )
7989
8090 const form = useForm < TelegramSettingsForm > ( {
8191 resolver : zodResolver ( telegramSettingsSchema ) ,
@@ -295,9 +305,38 @@ export default function TelegramSettings() {
295305 < Webhook className = "h-4 w-4" />
296306 { t ( 'settings.telegram.general.webhookUrl' ) }
297307 </ FormLabel >
298- < FormControl >
299- < Input type = "url" placeholder = { t ( 'settings.telegram.general.webhookUrlPlaceholder' ) } { ...field } className = "font-mono" />
300- </ FormControl >
308+ < div className = "relative" >
309+ < FormControl >
310+ < Input type = "url" placeholder = { t ( 'settings.telegram.general.webhookUrlPlaceholder' ) } { ...field } className = "font-mono pr-10" />
311+ </ FormControl >
312+ < Popover open = { popoverOpen } onOpenChange = { setPopoverOpen } >
313+ < PopoverTrigger asChild >
314+ < Button
315+ type = "button"
316+ variant = "ghost"
317+ size = "icon"
318+ className = "absolute right-1 top-1/2 h-8 w-8 -translate-y-1/2 hover:bg-accent"
319+ onClick = { ( e ) => {
320+ e . preventDefault ( )
321+ const currentUrl = getCurrentPanelUrl ( )
322+ field . onChange ( currentUrl )
323+ toast . success ( t ( 'settings.telegram.general.panelUrlApplied' ) )
324+ setPopoverOpen ( false )
325+ } }
326+ onMouseEnter = { ( ) => setPopoverOpen ( true ) }
327+ onMouseLeave = { ( ) => setPopoverOpen ( false ) }
328+ >
329+ < RefreshCcw className = "h-3 w-3" />
330+ </ Button >
331+ </ PopoverTrigger >
332+ < PopoverContent className = "w-80" side = "top" align = "end" >
333+ < div className = "space-y-2" >
334+ < p className = "text-sm font-medium" > { t ( 'settings.telegram.general.usePanelUrl' ) } </ p >
335+ < p className = "text-xs text-muted-foreground" > { t ( 'settings.telegram.general.usePanelUrlDescription' ) } </ p >
336+ </ div >
337+ </ PopoverContent >
338+ </ Popover >
339+ </ div >
301340 < FormDescription className = "text-sm text-muted-foreground" >
302341 { t ( 'settings.telegram.general.webhookUrlDescription' ) }
303342 < br />
0 commit comments