mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
Update TopUpModal.tsx
This commit is contained in:
@@ -19,7 +19,10 @@ const buildCryptoBotDeepLink = (url: string): string | null => {
|
|||||||
return `tg://resolve?domain=CryptoBot${parsed.search || ''}`
|
return `tg://resolve?domain=CryptoBot${parsed.search || ''}`
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
} catch { return null }
|
} catch (e) {
|
||||||
|
console.warn('[TopUpModal] Failed to build CryptoBot deep link:', e)
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const openPaymentLink = (url: string, reservedWindow?: Window | null) => {
|
const openPaymentLink = (url: string, reservedWindow?: Window | null) => {
|
||||||
@@ -28,7 +31,7 @@ const openPaymentLink = (url: string, reservedWindow?: Window | null) => {
|
|||||||
|
|
||||||
// If inside Telegram Mini App, let Telegram handle t.me links
|
// If inside Telegram Mini App, let Telegram handle t.me links
|
||||||
if (isTelegramPaymentLink(url) && webApp?.openTelegramLink) {
|
if (isTelegramPaymentLink(url) && webApp?.openTelegramLink) {
|
||||||
try { webApp.openTelegramLink(url); return } catch { /* ignore */ }
|
try { webApp.openTelegramLink(url); return } catch (e) { console.warn('[TopUpModal] openTelegramLink failed:', e) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefer Telegram deep link specifically for CryptoBot invoices, but only when
|
// Prefer Telegram deep link specifically for CryptoBot invoices, but only when
|
||||||
@@ -37,7 +40,7 @@ const openPaymentLink = (url: string, reservedWindow?: Window | null) => {
|
|||||||
const target = cb && !isTelegramPaymentLink(url) ? cb : url
|
const target = cb && !isTelegramPaymentLink(url) ? cb : url
|
||||||
|
|
||||||
if (reservedWindow && !reservedWindow.closed) {
|
if (reservedWindow && !reservedWindow.closed) {
|
||||||
try { reservedWindow.location.href = target; reservedWindow.focus?.() } catch { /* ignore */ }
|
try { reservedWindow.location.href = target; reservedWindow.focus?.() } catch (e) { console.warn('[TopUpModal] Failed to use reserved window:', e) }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +139,7 @@ export default function TopUpModal({ method, onClose }: TopUpModalProps) {
|
|||||||
onClose()
|
onClose()
|
||||||
},
|
},
|
||||||
onError: (error: unknown) => {
|
onError: (error: unknown) => {
|
||||||
try { if (popupRef.current && !popupRef.current.closed) popupRef.current.close() } catch { /* ignore */ }
|
try { if (popupRef.current && !popupRef.current.closed) popupRef.current.close() } catch (e) { console.warn('[TopUpModal] Failed to close popup:', e) }
|
||||||
popupRef.current = null
|
popupRef.current = null
|
||||||
const detail = (error as { response?: { data?: { detail?: string } } })?.response?.data?.detail || ''
|
const detail = (error as { response?: { data?: { detail?: string } } })?.response?.data?.detail || ''
|
||||||
if (detail.includes('not yet implemented')) setError(t('balance.useBot'))
|
if (detail.includes('not yet implemented')) setError(t('balance.useBot'))
|
||||||
|
|||||||
Reference in New Issue
Block a user